[Bug 63216] New: cpp parser breaks on compound literals

Richard Moats rmoats-web at crypticus.net
Mon Aug 25 04:33:08 UTC 2003


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
     
http://bugs.kde.org/show_bug.cgi?id=63216     
           Summary: cpp parser breaks on compound literals
           Product: kdevelop
           Version: unspecified
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: kdevelop-devel at kdevelop.org
        ReportedBy: rmoats-web at crypticus.net


Version:           3.0 CVS (8/23/03) (using KDE Devel)
Installed from:    Compiled sources
Compiler:          i686-pc-linux-gnu-gcc (GCC) 3.3.2 20030812 (Debian prerelease) 
OS:          Linux

When the cppparser runs into a compound literal in a function/method, it hiccups and causes other function-scope variables and function calls to appear as global symbols in the class browser:

void foo( float[2] );

void compoundLiteralTest()
{
  foo( (float[]){ 0.0f, 1.0f } );
  int anotherVar; // appears as global scope in the class browser
  ...
}

This construct parsed fine until these lines were added to Parse::skip() in lib/cppparser/parser.cpp (rev 1.3):

        else if( l != '{' && (tk == '{' || tk == '}' || tk == ';') )
            return false;

which causes Parse::skip( '(', ')' ) to error out while skipping through "( (float[]){ 0.0f, 1.0f } )"

While compound literals aren't legal in ANSI C++, they are in C99 and GNU C++ extensions...




More information about the KDevelop-devel mailing list