Author: dgregor
Date: Sun Oct  9 17:57:49 2011
New Revision: 141521

URL: http://llvm.org/viewvc/llvm-project?rev=141521&view=rev
Log:
Push "out-of-line" declarations into scope when their lexical/semantic
redeclaration contexts are the same, as occurs within linkage
specifications. Fixes PR9162.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/linkage-spec.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=141521&r1=141520&r2=141521&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct  9 17:57:49 2011
@@ -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.

Modified: cfe/trunk/test/SemaCXX/linkage-spec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage-spec.cpp?rev=141521&r1=141520&r2=141521&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/linkage-spec.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage-spec.cpp Sun Oct  9 17:57:49 2011
@@ -89,3 +89,16 @@
 
 // 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);
+  }
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to