]> granicus.if.org Git - clang/commitdiff
Fix a crash that occurs in this C++ case:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 21 Jul 2009 06:43:26 +0000 (06:43 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 21 Jul 2009 06:43:26 +0000 (06:43 +0000)
struct foo {
  static bool value;
};
bool (foo::value); // crash because of parens

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

include/clang/Parse/Parser.h
test/SemaCXX/nested-name-spec.cpp

index 677cd819ca271bc63425de8bce01d0bdd02205fb..50145ae5300b1e018bcce90dc066b1e44acd238a 100644 (file)
@@ -1080,17 +1080,22 @@ private:
   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);
+      }
     }
   };
   
index 8fff8a2b2cbc443322386143ed6a1009cd380f3d..97f31033e8ab6b163b2d4b9d658a32bf9cfee297 100644 (file)
@@ -172,7 +172,10 @@ X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
       // 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 {