Fix a dangerous c-cast in the cpp codegen

This commit is contained in:
Denis Blank 2016-11-24 17:03:53 +01:00
parent 3a8ec78de2
commit c8279a1d89
2 changed files with 3 additions and 2 deletions

View File

@ -123,3 +123,4 @@ YYYY/MM/DD, github id, Full name, email
2016/11/25, MrSampson, Oliver Sampson, olsam@quickaudio.com
2016/11/29, millergarym, Gary Miller, miller.garym@gmail.com
2016/11/29, wxio, Gary Miller, gm@wx.io
2016/11/29, Naios, Denis Blank, naios@users.noreply.github.com

View File

@ -1048,8 +1048,8 @@ virtual antlrcpp::Any accept(tree::ParseTreeVisitor *visitor) override;
VisitorDispatchMethod(method) ::= <<
antlrcpp::Any <parser.name>::<struct.name>::accept(tree::ParseTreeVisitor *visitor) {
if (dynamic_cast\<<parser.grammarName>Visitor*>(visitor) != nullptr)
return ((<parser.grammarName>Visitor *)visitor)->visit<struct.derivedFromName; format="cap">(this);
if (auto parserVisitor = dynamic_cast\<<parser.grammarName>Visitor*>(visitor))
return parserVisitor->visit<struct.derivedFromName; format="cap">(this);
else
return visitor->visitChildren(this);
}