diff options
-rw-r--r-- | include/clang/Parse/Action.h | 2 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 2 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/Sema/SemaCXXScopeSpec.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/default2.cpp | 7 |
6 files changed, 16 insertions, 10 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index bfb32000d0..af72554908 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -152,7 +152,7 @@ public: /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. /// Used to indicate that names should revert to being looked up in the /// defining scope. - virtual void ActOnCXXExitDeclaratorScope(const CXXScopeSpec &SS) { + virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { } /// ActOnDeclarator - This callback is invoked when a declarator is parsed and diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index d6a3efdd5e..ba5cc84b99 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -819,7 +819,7 @@ private: ~DeclaratorScopeObj() { if (SS.isSet()) - P.Actions.ActOnCXXExitDeclaratorScope(SS); + P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS); } }; diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index bebd0cfe74..6ce3ec5dd3 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -903,7 +903,7 @@ public: /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. /// Used to indicate that names should revert to being looked up in the /// defining scope. - virtual void ActOnCXXExitDeclaratorScope(const CXXScopeSpec &SS); + virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS); // ParseObjCStringLiteral - Parse Objective-C string literals. virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index 193e259f1d..8b3218b33b 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -134,8 +134,8 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S, void Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
assert(PreDeclaratorDC == 0 && "Previous declarator context not popped?");
- PreDeclaratorDC = CurContext;
- CurContext = static_cast<DeclContext*>(SS.getScopeRep());
+ PreDeclaratorDC = static_cast<DeclContext*>(S->getEntity());
+ S->setEntity(static_cast<DeclContext*>(SS.getScopeRep()));
}
/// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
@@ -143,10 +143,9 @@ void Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) { /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
/// Used to indicate that names should revert to being looked up in the
/// defining scope.
-void Sema::ActOnCXXExitDeclaratorScope(const CXXScopeSpec &SS) {
+void Sema::ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
- assert(CurContext == static_cast<DeclContext*>(SS.getScopeRep()) &&
- "Context imbalance!");
- CurContext = PreDeclaratorDC;
+ assert(S->getEntity() == SS.getScopeRep() && "Context imbalance!");
+ S->setEntity(PreDeclaratorDC);
PreDeclaratorDC = 0;
}
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 1be30715e5..5e0edcd1ec 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -221,7 +221,7 @@ ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) { Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S, const DeclContext *LookupCtx, bool enableLazyBuiltinCreation, - bool LookInParent) { + bool LookInParent) { if (!Name) return 0; unsigned NS = NSI; if (getLangOptions().CPlusPlus && (NS & Decl::IDNS_Ordinary)) diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp index 6a8bcb121c..e5fe48d1cb 100644 --- a/test/SemaCXX/default2.cpp +++ b/test/SemaCXX/default2.cpp @@ -68,5 +68,12 @@ class Y { int mem1(int i = a); // expected-error{{invalid use of nonstatic data member 'a'}} // FIXME: The code below is well-formed. // int mem2(int i = b); // OK; use X::b + int mem3(int i); + int mem4(int i); static int b; }; + +int Y::mem3(int i = b) { return i; } // OK; use X::b + +int Y::mem4(int i = a) // expected-error{{invalid use of nonstatic data member 'a'}} +{ return i; } |