[cfe-commits] r38904 - /cfe/cfe/trunk/Parse/ParseDecl.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:25:38 PDT 2007


Author: sabre
Date: Wed Jul 11 11:25:38 2007
New Revision: 38904

URL: http://llvm.org/viewvc/llvm-project?rev=38904&view=rev
Log:
Set TypeSpecType on 'struct x' with no body.

Modified:
    cfe/cfe/trunk/Parse/ParseDecl.cpp

Modified: cfe/cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseDecl.cpp?rev=38904&r1=38903&r2=38904&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:38 2007
@@ -343,74 +343,73 @@
   if (Tok.getKind() == tok::identifier)
     ConsumeToken();
   
-  if (Tok.getKind() != tok::l_brace)
-    return;
-  
-  SourceLocation LBraceLoc = Tok.getLocation();
-  ConsumeBrace();
+  if (Tok.getKind() == tok::l_brace) {
+    SourceLocation LBraceLoc = Tok.getLocation();
+    ConsumeBrace();
+
+    if (Tok.getKind() == tok::r_brace)
+      Diag(Tok, diag::ext_empty_struct_union_enum, isUnion ? "union":"struct");
+
+    while (Tok.getKind() != tok::r_brace && 
+           Tok.getKind() != tok::eof) {
+      // Each iteration of this loop reads one struct-declaration.
 
-  if (Tok.getKind() == tok::r_brace)
-    Diag(Tok, diag::ext_empty_struct_union_enum, isUnion ? "union" : "struct");
+      // Parse the common specifier-qualifiers-list piece.
+      DeclSpec DS;
+      SourceLocation SpecQualLoc = Tok.getLocation();
+      ParseSpecifierQualifierList(DS);
+      // TODO: Does specifier-qualifier list correctly check that *something* is
+      // specified?
+      
+      Declarator DeclaratorInfo(DS, Declarator::MemberContext);
 
-  while (Tok.getKind() != tok::r_brace && 
-         Tok.getKind() != tok::eof) {
-    // Each iteration of this loop reads one struct-declaration.
-
-    // Parse the common specifier-qualifiers-list piece.
-    DeclSpec DS;
-    SourceLocation SpecQualLoc = Tok.getLocation();
-    ParseSpecifierQualifierList(DS);
-    // TODO: Does specifier-qualifier list correctly check that *something* is
-    // specified?
-    
-    Declarator DeclaratorInfo(DS, Declarator::MemberContext);
-
-    // If there are no declarators, issue a warning.
-    if (Tok.getKind() == tok::semi) {
-      Diag(SpecQualLoc, diag::w_no_declarators);
-    } else {
-      // Read struct-declarators until we find the semicolon.
-      while (1) {
-        /// struct-declarator: declarator
-        /// struct-declarator: declarator[opt] ':' constant-expression
-        if (Tok.getKind() != tok::colon)
-          ParseDeclarator(DeclaratorInfo);
-        
-        if (Tok.getKind() == tok::colon) {
-          ConsumeToken();
-          ExprResult Res = ParseConstantExpression();
-          if (Res.isInvalid) {
-            SkipUntil(tok::semi, true, true);
-          } else {
-            // Process it.
+      // If there are no declarators, issue a warning.
+      if (Tok.getKind() == tok::semi) {
+        Diag(SpecQualLoc, diag::w_no_declarators);
+      } else {
+        // Read struct-declarators until we find the semicolon.
+        while (1) {
+          /// struct-declarator: declarator
+          /// struct-declarator: declarator[opt] ':' constant-expression
+          if (Tok.getKind() != tok::colon)
+            ParseDeclarator(DeclaratorInfo);
+          
+          if (Tok.getKind() == tok::colon) {
+            ConsumeToken();
+            ExprResult Res = ParseConstantExpression();
+            if (Res.isInvalid) {
+              SkipUntil(tok::semi, true, true);
+            } else {
+              // Process it.
+            }
           }
-        }
 
-        // TODO: install declarator.
-        
-        // If we don't have a comma, it is either the end of the list (a ';') or
-        // an error, bail out.
-        if (Tok.getKind() != tok::comma)
-          break;
-        
-        // Consume the comma.
+          // TODO: install declarator.
+          
+          // If we don't have a comma, it is either the end of the list (a ';')
+          // or an error, bail out.
+          if (Tok.getKind() != tok::comma)
+            break;
+          
+          // Consume the comma.
+          ConsumeToken();
+          
+          // Parse the next declarator.
+          DeclaratorInfo.clear();
+        }
+      }
+      
+      if (Tok.getKind() == tok::semi) {
         ConsumeToken();
-        
-        // Parse the next declarator.
-        DeclaratorInfo.clear();
+      } else {
+        Diag(Tok, diag::err_expected_semi_decl_list);
+        // Skip to end of block or statement
+        SkipUntil(tok::r_brace, true, true);
       }
     }
-    
-    if (Tok.getKind() == tok::semi) {
-      ConsumeToken();
-    } else {
-      Diag(Tok, diag::err_expected_semi_decl_list);
-      // Skip to end of block or statement
-      SkipUntil(tok::r_brace, true, true);
-    }
-  }
 
-  MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",diag::err_expected_rbrace);
+    MatchRHSPunctuation(tok::r_brace, LBraceLoc, "{",diag::err_expected_rbrace);
+  }
 
   const char *PrevSpec = 0;
   if (DS.SetTypeSpecType(isUnion ? DeclSpec::TST_union : DeclSpec::TST_struct,





More information about the cfe-commits mailing list