]> granicus.if.org Git - clang/commitdiff
Add ThreadSpecified bit to Decl.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 8 Sep 2008 20:05:47 +0000 (20:05 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 8 Sep 2008 20:05:47 +0000 (20:05 +0000)
 - Patch from Kevin Tew.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55940 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/Sema/SemaDecl.cpp

index a13f0532da29cb01d1572413dabcc1976e41a631..29ec40b6e213dda41e485c3bef2416adbdab1e8f 100644 (file)
@@ -228,12 +228,14 @@ private:
   Stmt *Init;
   // FIXME: This can be packed into the bitfields in Decl.
   unsigned SClass : 3;
+  bool ThreadSpecified : 1;
   
   friend class StmtIteratorBase;
 protected:
   VarDecl(Kind DK, DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
           QualType T, StorageClass SC, ScopedDecl *PrevDecl)
-    : ValueDecl(DK, DC, L, Id, T, PrevDecl), Init(0) { SClass = SC; }
+    : ValueDecl(DK, DC, L, Id, T, PrevDecl), Init(0),
+          ThreadSpecified(false) { SClass = SC; }
 public:
   static VarDecl *Create(ASTContext &C, DeclContext *DC,
                          SourceLocation L, IdentifierInfo *Id,
@@ -245,6 +247,11 @@ public:
   Expr *getInit() { return (Expr*) Init; }
   void setInit(Expr *I) { Init = (Stmt*) I; }
       
+  void setThreadSpecified(bool T) { ThreadSpecified = T; }
+  bool isThreadSpecified() const {
+    return ThreadSpecified;
+  }
+  
   /// hasLocalStorage - Returns true if a variable with function scope
   ///  is a non-static local variable.
   bool hasLocalStorage() const {
index 75fcc5173ed4a8d5413e968133a05fa060c830ab..cf84bcc5e1e87f12c38dc7787a4c226b1b47aafe 100644 (file)
@@ -743,6 +743,7 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
                                       D.getIdentifierLoc(), II,
                                       R, LastDeclarator);
     } else {
+      bool ThreadSpecified = D.getDeclSpec().isThreadSpecified();
       if (S->getFnParent() == 0) {
         // C99 6.9p2: The storage-class specifiers auto and register shall not
         // appear in the declaration specifiers in an external declaration.
@@ -751,12 +752,10 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
                R.getAsString());
           InvalidDecl = true;
         }
-        NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
-                                II, R, SC, LastDeclarator);
-      } else {
-        NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
-                                II, R, SC, LastDeclarator);
       }
+        NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(), 
+                                II, R, SC, LastDeclarator);
+        NewVD->setThreadSpecified(ThreadSpecified);
     }
     // Handle attributes prior to checking for duplicates in MergeVarDecl
     ProcessDeclAttributes(NewVD, D);