[cfe-dev] Regression when parsing (padding) bitfields.

Enea Zaffanella zaffanella at cs.unipr.it
Mon Jul 2 02:36:45 PDT 2012


Hello.

When parsing the following program

$ cat bug.c
struct S {
   enum V0 { v0 };
   enum V0 e0 : 8;
   enum V0 : 4;

   enum V1 { v1 } e1 : 8;
   enum V2 { v2 } : 4; // Parse error.
};

recent version of clang accept all but the last (unnamed) bitfield 
declaration, yielding the following error messages:

$ Debug+Asserts/bin/clang -fsyntax-only bug.c
bug.c:7:18: error: expected
       ';' after enum
   enum V2 { v2 } : 4; // Parse error.
                  ^
                  ;
bug.c:7:20: error: type name
       requires a specifier or qualifier
   enum V2 { v2 } : 4; // Parse error.
                    ^
bug.c:7:20: error: expected
       member name or ';' after declaration specifiers
   enum V2 { v2 } : 4; // Parse error.
                    ^
bug.c:7:21: error: expected
       ';' at end of declaration list
   enum V2 { v2 } : 4; // Parse error.
                     ^
                     ;
4 errors generated.


Previous versions of clang (e.g., up to r158293) were parsing the 
program without generating diagnostics.

Cheers,
Enea.



More information about the cfe-dev mailing list