diff options
author | John McCall <rjmccall@apple.com> | 2009-11-11 00:21:18 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-11-11 00:21:18 +0000 |
commit | f7f3d0db754db0500b56d49ac19f795f13965912 (patch) | |
tree | a22ddc56d716d877758c633d4708858b3817997a | |
parent | 0f9fed70cea107b3f79df554e38bd8e98d48fe47 (diff) |
Create a new Scope when parsing a declaration with a C++ scope specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86764 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Parse/Parser.h | 9 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 3 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp | 13 |
3 files changed, 21 insertions, 4 deletions
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index b163c81e18..dd939a98bf 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -1226,13 +1226,18 @@ private: Parser &P; CXXScopeSpec &SS; bool EnteredScope; + bool CreatedScope; public: DeclaratorScopeObj(Parser &p, CXXScopeSpec &ss) - : P(p), SS(ss), EnteredScope(false) {} + : P(p), SS(ss), EnteredScope(false), CreatedScope(false) {} void EnterDeclaratorScope() { assert(!EnteredScope && "Already entered the scope!"); assert(SS.isSet() && "C++ scope was not set!"); + + CreatedScope = true; + P.EnterScope(0); // Not a decl scope. + if (P.Actions.ActOnCXXEnterDeclaratorScope(P.CurScope, SS)) SS.setScopeRep(0); @@ -1245,6 +1250,8 @@ private: assert(SS.isSet() && "C++ scope was cleared ?"); P.Actions.ActOnCXXExitDeclaratorScope(P.CurScope, SS); } + if (CreatedScope) + P.ExitScope(); } }; diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 31e64a9f8b..13a66aaca0 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -90,9 +90,6 @@ namespace { assert(InnermostFileDC && InnermostFileDC->isFileContext()); for (; S; S = S->getParent()) { - if (!(S->getFlags() & Scope::DeclScope)) - continue; - if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity())) { DeclContext *EffectiveDC = (Ctx->isFileContext() ? Ctx : InnermostFileDC); visit(Ctx, EffectiveDC); diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp index 5b8aadf391..fbd205833c 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp @@ -126,3 +126,16 @@ namespace test4 { return foo(); // expected-error {{call to 'foo' is ambiguous}} } } + +// Bug: using directives should be followed when parsing default +// arguments in scoped declarations. +class test5 { + int inc(int x); +}; +namespace Test5 { + int default_x = 0; +} +using namespace Test5; +int test5::inc(int x = default_x) { + return x+1; +} |