Author: rsmith
Date: Sun Mar 23 14:45:26 2014
New Revision: 204568

URL: http://llvm.org/viewvc/llvm-project?rev=204568&view=rev
Log:
When we inject a declaration into a namespace, add the primary DeclContext to
the update set rather than the current DeclContext. Add test for the local
extern case too.

Modified:
    cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
    cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
    cfe/trunk/test/Modules/Inputs/cxx-templates-common.h
    cfe/trunk/test/Modules/cxx-templates.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sun Mar 23 14:45:26 2014
@@ -185,8 +185,9 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
   // function with a local extern declaration, for instance.
   if (D->isOutOfLine()) {
     auto *NS = 
dyn_cast<NamespaceDecl>(D->getDeclContext()->getRedeclContext());
+    // FIXME: Also update surrounding inline namespaces.
     if (NS && NS->isFromASTFile())
-      Writer.AddUpdatedDeclContext(NS);
+      Writer.AddUpdatedDeclContext(NS->getPrimaryContext());
   }
 }
 

Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-b.h?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-b.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-b.h Sun Mar 23 14:45:26 2014
@@ -66,4 +66,5 @@ template<typename T> void UseDefinedInBI
 
 void TriggerInstantiation() {
   UseDefinedInBImpl<void>();
+  Std::f<int>();
 }

Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-common.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-common.h?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-common.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-common.h Sun Mar 23 14:45:26 
2014
@@ -15,3 +15,9 @@ namespace Std {
     friend bool operator!=(const WithFriend &A, const WithFriend &B) { return 
false; }
   };
 }
+
+namespace Std {
+  template<typename T> void f() {
+    extern T g();
+  }
+}

Modified: cfe/trunk/test/Modules/cxx-templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-templates.cpp?rev=204568&r1=204567&r2=204568&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-templates.cpp (original)
+++ cfe/trunk/test/Modules/cxx-templates.cpp Sun Mar 23 14:45:26 2014
@@ -121,6 +121,11 @@ bool testFriendInClassTemplate(Std::With
   return wfi != wfi;
 }
 
+namespace Std {
+  void g(); // expected-error {{functions that differ only in their return 
type cannot be overloaded}}
+  // [email protected]:21 {{previous}}
+}
+
 // CHECK-GLOBAL:      DeclarationName 'f'
 // CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
 // CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'


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

Reply via email to