r241182 - [modules] Don't make out-of-line member specializations of an instantiated

Richard Smith richard-llvm at metafoo.co.uk
Wed Jul 1 12:32:54 PDT 2015


Author: rsmith
Date: Wed Jul  1 14:32:54 2015
New Revision: 241182

URL: http://llvm.org/viewvc/llvm-project?rev=241182&view=rev
Log:
[modules] Don't make out-of-line member specializations of an instantiated
class template specialization visible just because the class template
specialization's definition is visible.

Modified:
    cfe/trunk/lib/AST/DeclBase.cpp
    cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
    cfe/trunk/test/Modules/submodules-merge-defs.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=241182&r1=241181&r2=241182&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Jul  1 14:32:54 2015
@@ -236,6 +236,7 @@ void Decl::setLexicalDeclContext(DeclCon
   } else {
     getMultipleDC()->LexicalDC = DC;
   }
+  Hidden = cast<Decl>(DC)->Hidden;
 }
 
 void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,

Modified: cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h?rev=241182&r1=241181&r2=241182&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h (original)
+++ cfe/trunk/test/Modules/Inputs/submodules-merge-defs/defs.h Wed Jul  1 14:32:54 2015
@@ -10,6 +10,7 @@ public:
 // Check that lookup and access checks are performed in the right context.
 struct B::Inner2 : Inner1 {};
 template<typename T> void B::f() {}
+template<> inline void B::f<int>() {}
 
 // Check that base-specifiers are correctly disambiguated.
 template<int N> struct C_Base { struct D { constexpr operator int() const { return 0; } }; };
@@ -31,7 +32,8 @@ template<typename T> struct F {
 template<typename T> int F<T>::f() { return 0; }
 template<typename T> template<typename U> int F<T>::g() { return 0; }
 template<typename T> int F<T>::n = 0;
-//template<> template<typename U> int F<char>::g() { return 0; } // FIXME: Re-enable this once we support merging member specializations.
+template<> inline int F<char>::f() { return 0; }
+template<> template<typename U> int F<char>::g() { return 0; }
 template<> struct F<void> { int h(); };
 inline int F<void>::h() { return 0; }
 template<typename T> struct F<T *> { int i(); };

Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=241182&r1=241181&r2=241182&view=diff
==============================================================================
--- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original)
+++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Wed Jul  1 14:32:54 2015
@@ -27,33 +27,37 @@ int pre_use_a = use_a(pre_a); // expecte
 B::Inner2 pre_bi; // expected-error +{{must be imported}}
 // expected-note at defs.h:4 +{{here}}
 // expected-note at defs.h:11 +{{here}}
+void pre_bfi(B b) { // expected-error {{must use 'class'}} expected-error +{{must be imported}}
+  b.f<int>(); // expected-error +{{must be imported}} expected-error +{{}}
+  // expected-note at defs.h:12 +{{here}}
+}
 
 C_Base<1> pre_cb1; // expected-error +{{must be imported}}
-// expected-note at defs.h:15 +{{here}}
+// expected-note at defs.h:16 +{{here}}
 C1 pre_c1; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}
-// expected-note at defs.h:17 +{{here}}
-C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}
 // expected-note at defs.h:18 +{{here}}
+C2 pre_c2; // expected-error +{{must be imported}} expected-error {{must use 'struct'}}
+// expected-note at defs.h:19 +{{here}}
 
 D::X pre_dx; // expected-error +{{must be imported}}
-// expected-note at defs.h:20 +{{here}}
 // expected-note at defs.h:21 +{{here}}
+// expected-note at defs.h:22 +{{here}}
 // FIXME: We should warn that use_dx is being used without being imported.
 int pre_use_dx = use_dx(pre_dx);
 
 int pre_e = E(0); // expected-error {{must be imported}}
-// expected-note at defs.h:24 +{{here}}
+// expected-note at defs.h:25 +{{here}}
 
 int pre_ff = F<int>().f(); // expected-error +{{must be imported}}
 int pre_fg = F<int>().g<int>(); // expected-error +{{must be imported}}
-// expected-note at defs.h:26 +{{here}}
+// expected-note at defs.h:27 +{{here}}
 
 G::A pre_ga // expected-error +{{must be imported}}
   = G::a; // expected-error +{{must be imported}}
-// expected-note at defs.h:40 +{{here}}
-// expected-note at defs.h:41 +{{here}}
-decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}}
 // expected-note at defs.h:42 +{{here}}
+// expected-note at defs.h:43 +{{here}}
+decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}}
+// expected-note at defs.h:44 +{{here}}
 
 J<> pre_j; // expected-error {{declaration of 'J' must be imported}}
 #ifdef IMPORT_USE_2
@@ -63,7 +67,7 @@ J<> pre_j; // expected-error {{declarati
 #else
 // expected-error at -6 {{default argument of 'J' must be imported from module 'stuff.use'}}
 #endif
-// expected-note at defs.h:49 +{{here}}
+// expected-note at defs.h:51 +{{here}}
 
 // Make definitions from second module visible.
 #ifdef TEXTUAL
@@ -77,6 +81,9 @@ J<> pre_j; // expected-error {{declarati
 A post_a;
 int post_use_a = use_a(post_a);
 B::Inner2 post_bi;
+void post_bfi(B b) {
+  b.f<int>();
+}
 C_Base<1> post_cb1;
 C1 c1;
 C2 c2;





More information about the cfe-commits mailing list