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

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


Author: sabre
Date: Wed Jul 11 11:42:12 2007
New Revision: 39268

URL: http://llvm.org/viewvc/llvm-project?rev=39268&view=rev
Log:
invoke a new callback when starting to parse a struct/union tag

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=39268&r1=39267&r2=39268&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/cfe/trunk/Parse/ParseDecl.cpp Wed Jul 11 11:42:12 2007
@@ -439,12 +439,24 @@
   if (Tok.getKind() != tok::identifier &&
       Tok.getKind() != tok::l_brace) {
     Diag(Tok, diag::err_expected_ident_lbrace);
+    // TODO: better error recovery here.
     return;
   }
   
-  if (Tok.getKind() == tok::identifier)
-    ConsumeToken();
+  // If an identifier is present, consume and remember it.
+  IdentifierInfo *Name = 0;
+  SourceLocation NameLoc;
+  if (Tok.getKind() == tok::identifier) {
+    Name = Tok.getIdentifierInfo();
+    NameLoc = ConsumeToken();
+  }
   
+  // There are three options here.  If we have 'struct foo;', then this is a
+  // forward declaration.  If we have 'struct foo {...' then this is a
+  // definition.  Otherwise we have something like 'struct foo xyz', a use.
+  DeclTy *TagDecl = Actions.ParseStructUnionTag(CurScope, isUnion, StartLoc,
+                                                Name, NameLoc);
+  // TODO: more with the tag decl.
   if (Tok.getKind() == tok::l_brace) {
     SourceLocation LBraceLoc = ConsumeBrace();
 





More information about the cfe-commits mailing list