Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-36367

Misleading error output of moc on unknown symbols

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.2, 6.6.0
    • 5.2.0
    • Build tools: moc
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            krf Kevin Funk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes