Browse Source

Test that we can merge together explicit and partial specializations from
merged declarations of a class template.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192746 91177308-0d34-0410-b5e6-96231b3b80d8

Richard Smith 12 years ago
parent
commit
7a3dfcdfb3

+ 8 - 0
test/Modules/Inputs/cxx-templates-a.h

@@ -40,3 +40,11 @@ const auto enum_c_from_a = CommonTemplate<int>::c;
 template<int> struct UseInt;
 template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
 constexpr void (*UseRedeclaredEnumA)(UseInt<1>) = UseRedeclaredEnum<int>;
+
+template<typename> struct MergeSpecializations;
+template<typename T> struct MergeSpecializations<T*> {
+  typedef int partially_specialized_in_a;
+};
+template<> struct MergeSpecializations<char> {
+  typedef int explicitly_specialized_in_a;
+};

+ 8 - 0
test/Modules/Inputs/cxx-templates-b.h

@@ -51,6 +51,14 @@ template<int> struct UseInt;
 template<typename T> void UseRedeclaredEnum(UseInt<T() + CommonTemplate<char>::a>);
 constexpr void (*UseRedeclaredEnumB)(UseInt<1>) = UseRedeclaredEnum<int>;
 
+template<typename> struct MergeSpecializations;
+template<typename T> struct MergeSpecializations<T&> {
+  typedef int partially_specialized_in_b;
+};
+template<> struct MergeSpecializations<double> {
+  typedef int explicitly_specialized_in_b;
+};
+
 @import cxx_templates_a;
 template<typename T> void UseDefinedInBImplIndirectly(T &v) {
   PerformDelayedLookup(v);

+ 7 - 0
test/Modules/Inputs/cxx-templates-c.h

@@ -0,0 +1,7 @@
+template<typename> struct MergeSpecializations;
+template<typename T> struct MergeSpecializations<T[]> {
+  typedef int partially_specialized_in_c;
+};
+template<> struct MergeSpecializations<bool> {
+  typedef int explicitly_specialized_in_c;
+};

+ 4 - 0
test/Modules/Inputs/module.map

@@ -204,6 +204,10 @@ module cxx_templates_b {
   header "cxx-templates-b.h"
 }
 
+module cxx_templates_c {
+  header "cxx-templates-c.h"
+}
+
 module cxx_decls {
   module unimported {
     header "cxx-decls-unimported.h"

+ 8 - 0
test/Modules/cxx-templates.cpp

@@ -5,6 +5,7 @@
 
 @import cxx_templates_a;
 @import cxx_templates_b;
+@import cxx_templates_c;
 @import cxx_templates_common;
 
 template<typename, char> struct Tmpl_T_C {};
@@ -93,6 +94,13 @@ RedeclaredAsFriend<int> raf1;
 RedeclareTemplateAsFriend<double> rtaf;
 RedeclaredAsFriend<double> raf2;
 
+MergeSpecializations<int*>::partially_specialized_in_a spec_in_a_1;
+MergeSpecializations<int&>::partially_specialized_in_b spec_in_b_1;
+MergeSpecializations<int[]>::partially_specialized_in_c spec_in_c_1;
+MergeSpecializations<char>::explicitly_specialized_in_a spec_in_a_2;
+MergeSpecializations<double>::explicitly_specialized_in_b spec_in_b_2;
+MergeSpecializations<bool>::explicitly_specialized_in_c spec_in_c_2;
+
 @import cxx_templates_common;
 
 typedef SomeTemplate<int*> SomeTemplateIntPtr;