[cfe-commits] r76538 - in /cfe/trunk: include/clang/Parse/Parser.h test/SemaCXX/nested-name-spec.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Mon Jul 20 23:43:26 PDT 2009


Author: akirtzidis
Date: Tue Jul 21 01:43:26 2009
New Revision: 76538

URL: http://llvm.org/viewvc/llvm-project?rev=76538&view=rev
Log:
Fix a crash that occurs in this C++ case:

struct foo {
  static bool value;
};
bool (foo::value); // crash because of parens

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/test/SemaCXX/nested-name-spec.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=76538&r1=76537&r2=76538&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Jul 21 01:43:26 2009
@@ -1080,17 +1080,22 @@
   class DeclaratorScopeObj {
     Parser &P;
     CXXScopeSpec &SS;
+    bool EnteredScope;
   public:
-    DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss) : P(p), SS(ss) {}
+    DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
+      : P(p), SS(ss), EnteredScope(false) {}
 
     void EnterDeclaratorScope() {
-      if (SS.isSet())
-        P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS);
+      assert(SS.isSet() && "C++ scope was not set!");
+      P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS);
+      EnteredScope = true;
     }
 
     ~DeclaratorScopeObj() {
-      if (SS.isSet())
+      if (EnteredScope) {
+        assert(SS.isSet() && "C++ scope was cleared ?");
         P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS);
+      }
     }
   };
   

Modified: cfe/trunk/test/SemaCXX/nested-name-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nested-name-spec.cpp?rev=76538&r1=76537&r2=76538&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/nested-name-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/nested-name-spec.cpp Tue Jul 21 01:43:26 2009
@@ -172,7 +172,10 @@
       // expected-error{{C++ requires a type specifier for all declarations}} \
       // expected-error{{only constructors take base initializers}}
 
-
+struct foo_S {
+  static bool value;
+};
+bool (foo_S::value);
 
 
 namespace somens {





More information about the cfe-commits mailing list