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
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5ba38ee..b1e4a4e 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -845,7 +845,9 @@
// 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.