antlr4
antlr4 copied to clipboard
C++ warning + fix
Using g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0 gives
antlr4/tree/ParseTree.h:50:18: warning: ‘virtual bool antlr4::tree::ParseTree::operator==(const antlr4::tree::ParseTree&) const’ was hidden [-Woverloaded-virtual=]
50 | virtual bool operator == (const ParseTree &other) const;
| ^~~~~~~~
antlr4/RuleContext.h:135:10: note: by ‘bool antlr4::RuleContext::operator==(const antlr4::RuleContext&)’
135 | bool operator == (const RuleContext &other) { return this == &other; } // Simple address comparison.
The operator== in RuleContext seems redundant, as the virtual one in ParseTree performs the same check?
Proposed fix: remove this line: https://github.com/antlr/antlr4/blob/1855d9aa4c5ebb15284b95a07048b6260304629c/runtime/Cpp/runtime/src/RuleContext.h#L135
Have you solved that? I face the same problem.
Yes, just remove the line above (135 in Rulecontext.h) as it does nothing different from the virtual method it reimplements.