Fix a crash that occurs in this C++ case:

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

llvm-svn: 76538
This commit is contained in:
Argyrios Kyrtzidis 2009-07-21 06:43:26 +00:00
parent 83423aa276
commit 1a176f0b96
2 changed files with 13 additions and 5 deletions

View File

@ -1080,18 +1080,23 @@ private:
class DeclaratorScopeObj { class DeclaratorScopeObj {
Parser &P; Parser &P;
CXXScopeSpec &SS; CXXScopeSpec &SS;
bool EnteredScope;
public: public:
DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss) : P(p), SS(ss) {} DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss)
: P(p), SS(ss), EnteredScope(false) {}
void EnterDeclaratorScope() { void EnterDeclaratorScope() {
if (SS.isSet()) assert(SS.isSet() && "C++ scope was not set!");
P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS); P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS);
EnteredScope = true;
} }
~DeclaratorScopeObj() { ~DeclaratorScopeObj() {
if (SS.isSet()) if (EnteredScope) {
assert(SS.isSet() && "C++ scope was cleared ?");
P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS); P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS);
} }
}
}; };
/// ParseDeclarator - Parse and verify a newly-initialized declarator. /// ParseDeclarator - Parse and verify a newly-initialized declarator.

View 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{{C++ requires a type specifier for all declarations}} \
// expected-error{{only constructors take base initializers}} // expected-error{{only constructors take base initializers}}
struct foo_S {
static bool value;
};
bool (foo_S::value);
namespace somens { namespace somens {