diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-09 22:57:49 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-09 22:57:49 +0000 |
commit | 6d0468b2d3aa37c699b697922cd991ae83b64a87 (patch) | |
tree | c5ae648f9a3ce81dba96afbbdb295add6391ef28 | |
parent | ac57f0b9097e04f70a631549383a2944f74ad844 (diff) |
Push "out-of-line" declarations into scope when their lexical/semantic
redeclaration contexts are the same, as occurs within linkage
specifications. Fixes PR9162.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141521 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/linkage-spec.cpp | 13 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5ba38ee9f2..b1e4a4e75b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -845,7 +845,9 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // Out-of-line definitions shouldn't be pushed into scope in C++. // Out-of-line variable and function definitions shouldn't even in C. if ((getLangOptions().CPlusPlus || isa<VarDecl>(D) || isa<FunctionDecl>(D)) && - D->isOutOfLine()) + D->isOutOfLine() && + !D->getDeclContext()->getRedeclContext()->Equals( + D->getLexicalDeclContext()->getRedeclContext())) return; // Template instantiations should also not be pushed into scope. diff --git a/test/SemaCXX/linkage-spec.cpp b/test/SemaCXX/linkage-spec.cpp index b5a10a795e..cb7e32c05d 100644 --- a/test/SemaCXX/linkage-spec.cpp +++ b/test/SemaCXX/linkage-spec.cpp @@ -89,3 +89,16 @@ extern "C++" using N::value; // PR7076 extern "C" const char *Version_string = "2.9"; + +namespace PR9162 { + extern "C" { + typedef struct _ArtsSink ArtsSink; + struct _ArtsSink { + int sink; + }; + } + int arts_sink_get_type() + { + return sizeof(ArtsSink); + } +} |