]> granicus.if.org Git - clang/commitdiff
Push "out-of-line" declarations into scope when their lexical/semantic
authorDouglas Gregor <dgregor@apple.com>
Sun, 9 Oct 2011 22:57:49 +0000 (22:57 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 9 Oct 2011 22:57:49 +0000 (22:57 +0000)
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

lib/Sema/SemaDecl.cpp
test/SemaCXX/linkage-spec.cpp

index 5ba38ee9f2376f31346bcca328a07ae4b10ac0e0..b1e4a4e75b18ba32cb3440a292db741589b8be3a 100644 (file)
@@ -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.
index b5a10a795ebc205939a897f31d1326453b9089eb..cb7e32c05d887080467afc86b007d77e16624cac 100644 (file)
@@ -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);
+  }
+}