summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-10-09 22:57:49 +0000
committerDouglas Gregor <dgregor@apple.com>2011-10-09 22:57:49 +0000
commitf7b98957ac1f9c69f8d4dfc5e526b4e4e6e6d416 (patch)
treeeddce45a0096c0e433de8ffd7e3661fdd78ff327
parent56636589ffd881eac56c57bd06c6b12f19762d16 (diff)
downloadbcm5719-llvm-f7b98957ac1f9c69f8d4dfc5e526b4e4e6e6d416.tar.gz
bcm5719-llvm-f7b98957ac1f9c69f8d4dfc5e526b4e4e6e6d416.zip
Push "out-of-line" declarations into scope when their lexical/semantic
redeclaration contexts are the same, as occurs within linkage specifications. Fixes PR9162. llvm-svn: 141521
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
-rw-r--r--clang/test/SemaCXX/linkage-spec.cpp13
2 files changed, 16 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5ba38ee9f23..b1e4a4e75b1 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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/clang/test/SemaCXX/linkage-spec.cpp b/clang/test/SemaCXX/linkage-spec.cpp
index b5a10a795eb..cb7e32c05d8 100644
--- a/clang/test/SemaCXX/linkage-spec.cpp
+++ b/clang/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);
+ }
+}
OpenPOWER on IntegriCloud