Merge pull request #1426 from Naios/master

Fix a dangerous c-cast in the cpp codegen
This commit is contained in:
Terence Parr 2016-11-29 10:53:04 -08:00 committed by GitHub
commit eeeb43f9a0
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);
}