[cfe-commits] r52855 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/Parser/cxx-class.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sat Jun 28 01:10:49 PDT 2008


Author: akirtzidis
Date: Sat Jun 28 03:10:48 2008
New Revision: 52855

URL: http://llvm.org/viewvc/llvm-project?rev=52855&view=rev
Log:
Handle unnamed bitfields when parsing C++ classes.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=52855&r1=52854&r2=52855&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Jun 28 03:10:48 2008
@@ -412,38 +412,41 @@
     }
   }
   
-  // Parse the first declarator.
   Declarator DeclaratorInfo(DS, Declarator::MemberContext);
-  ParseDeclarator(DeclaratorInfo);
-  // Error parsing the declarator?
-  if (DeclaratorInfo.getIdentifier() == 0) {
-    // If so, skip until the semi-colon or a }.
-    SkipUntil(tok::r_brace, true);
-    if (Tok.is(tok::semi))
-      ConsumeToken();
-    return 0;
-  }
 
-  // function-definition:
-  if (Tok.is(tok::l_brace)) {
-    if (!DeclaratorInfo.isFunctionDeclarator()) {
-      Diag(Tok, diag::err_func_def_no_params);
-      ConsumeBrace();
+  if (Tok.isNot(tok::colon)) {
+    // Parse the first declarator.
+    ParseDeclarator(DeclaratorInfo);
+    // Error parsing the declarator?
+    if (DeclaratorInfo.getIdentifier() == 0) {
+      // If so, skip until the semi-colon or a }.
       SkipUntil(tok::r_brace, true);
+      if (Tok.is(tok::semi))
+        ConsumeToken();
       return 0;
     }
 
-    if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
-      Diag(Tok, diag::err_function_declared_typedef);
-      // This recovery skips the entire function body. It would be nice
-      // to simply call ParseCXXInlineMethodDef() below, however Sema
-      // assumes the declarator represents a function, not a typedef.
-      ConsumeBrace();
-      SkipUntil(tok::r_brace, true);
-      return 0;
-    }
+    // function-definition:
+    if (Tok.is(tok::l_brace)) {
+      if (!DeclaratorInfo.isFunctionDeclarator()) {
+        Diag(Tok, diag::err_func_def_no_params);
+        ConsumeBrace();
+        SkipUntil(tok::r_brace, true);
+        return 0;
+      }
+
+      if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
+        Diag(Tok, diag::err_function_declared_typedef);
+        // This recovery skips the entire function body. It would be nice
+        // to simply call ParseCXXInlineMethodDef() below, however Sema
+        // assumes the declarator represents a function, not a typedef.
+        ConsumeBrace();
+        SkipUntil(tok::r_brace, true);
+        return 0;
+      }
 
-    return ParseCXXInlineMethodDef(AS, DeclaratorInfo);
+      return ParseCXXInlineMethodDef(AS, DeclaratorInfo);
+    }
   }
 
   // member-declarator-list:
@@ -510,7 +513,8 @@
     if (Tok.is(tok::kw___attribute))
       DeclaratorInfo.AddAttributes(ParseAttributes());
 
-    ParseDeclarator(DeclaratorInfo);
+    if (Tok.isNot(tok::colon))
+      ParseDeclarator(DeclaratorInfo);
   }
 
   if (Tok.is(tok::semi)) {

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=52855&r1=52854&r2=52855&view=diff

==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Sat Jun 28 03:10:48 2008
@@ -8,6 +8,7 @@
   struct S {};
   enum {};
   int; // expected-error {{error: declaration does not declare anything}}
+  int : 1, : 2;
 
 public:
   void m() {





More information about the cfe-commits mailing list