Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.2.0
-
None
-
d2242c353 (dev), 3afa4b266 (6.5)
Description
Example:
Have this line in some header:
Q_PROPERTY(Foo* foo NONSENSE foo)
=> /path/to/file.h:18: Parse error at "foo"
This is misleading, because the parse error actually happens later. MOC does not know 'NONSENSE' and therefore fails.
Looking at parser.cpp:
void Parser::error(const char *msg) { if (msg || error_msg) fprintf(stderr, ErrorFormatString "Error: %s\n", currentFilenames.top().constData(), symbol().lineNum, msg?msg:error_msg); else fprintf(stderr, ErrorFormatString "Parse error at \"%s\"\n", currentFilenames.top().constData(), symbol().lineNum, symbol().lexem().data()); exit(EXIT_FAILURE); }
Parse::error is called via Parser::next, this is where the parser aborts.
The lexeme is retrieved via symbol(), symbol() simply returns symbols.at(index-1). However, the Parser::test function just tested against symbols.at(index) and then failed. So this is clearly an off-by-one problem.
I don't really know the MOC code, so I'm rather posting this bug here instead of writing a patch that breaks things somewhere else.