[cfe-commits] r38854 - in /cfe/cfe/trunk: Parse/ParseDecl.cpp Parse/ParseStmt.cpp test/Parser/statements.c

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


Author: sabre
Date: Wed Jul 11 11:25:12 2007
New Revision: 38854

URL: http://llvm.org/viewvc/llvm-project?rev=38854&view=rev
Log:
Implement Parser/statements.c:test5: parsing decls that start with identifiers
in blocks.

Modified:
    cfe/cfe/trunk/Parse/ParseDecl.cpp
    cfe/cfe/trunk/Parse/ParseStmt.cpp
    cfe/cfe/trunk/test/Parser/statements.c

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

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:25:12 2007
@@ -42,7 +42,7 @@
     // Parse declarator '=' initializer.
     if (Tok.getKind() == tok::equal) {
       ConsumeToken();
-      // FIXME: THIS IS WRONG!!
+      // FIXME: THIS IS WRONG: should ParseInitializer!!
       ParseExpression();
     }
     

Modified: cfe/cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/ParseStmt.cpp?rev=38854&r1=38853&r2=38854&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseStmt.cpp Wed Jul 11 11:25:12 2007
@@ -191,9 +191,21 @@
   // declaration
   if (!OnlyStatement && 0/*Is typedef name!*/) {
     // Handle this.  Warn/disable if in middle of block and !C99.
+    DeclSpec DS;
+    
+    // FIXME: Add the typedef name to the start of the decl-specs.
+    // ParseDeclarationSpecifiers will continue from there.
+    ParseDeclarationSpecifiers(DS);
+
+    // Parse all the declarators.
+    Declarator DeclaratorInfo(DS, Declarator::BlockContext);
+    ParseDeclarator(DeclaratorInfo);
+    
+    ParseInitDeclaratorListAfterFirstDeclarator(DeclaratorInfo);
+    return;
   }
   
-  // Otherwise, this is an expression.
+  // Otherwise, this is an expression.  Seed it with II.
   
   assert(0);
 }

Modified: cfe/cfe/trunk/test/Parser/statements.c
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/test/Parser/statements.c?rev=38854&r1=38853&r2=38854&view=diff

==============================================================================
--- cfe/cfe/trunk/test/Parser/statements.c (original)
+++ cfe/cfe/trunk/test/Parser/statements.c Wed Jul 11 11:25:12 2007
@@ -37,3 +37,12 @@
   
 foo:  if (0);
 }
+
+typedef int t;
+void test5() {
+  if (0);
+
+  //t x = 0;      // FIXME: Enable when handling of typedef names is impl.
+
+  if (0);
+}





More information about the cfe-commits mailing list