Test that we can merge together explicit and partial specializations from
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Oct 2013 23:19:58 +0000 (23:19 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Oct 2013 23:19:58 +0000 (23:19 +0000)
merged declarations of a class template.

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

test/Modules/Inputs/cxx-templates-a.h
test/Modules/Inputs/cxx-templates-b.h
test/Modules/Inputs/cxx-templates-c.h [new file with mode: 0644]
test/Modules/Inputs/module.map
test/Modules/cxx-templates.cpp

index 0ca6e34d0bca602871b66c2bdc34f2c97af9ac46..0b1614d3d9e68b6f4163681af26f4787ba62df2d 100644 (file)
@@ -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;
+};
index f0921a7e0b2ddf84a02c8cbebd0e6b15b0894c5e..6cd83faf1a1bdae1e7605761b56cbcf920cfbb2f 100644 (file)
@@ -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);
diff --git a/test/Modules/Inputs/cxx-templates-c.h b/test/Modules/Inputs/cxx-templates-c.h
new file mode 100644 (file)
index 0000000..4c0fc8a
--- /dev/null
@@ -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;
+};
index ac3543b6440c43cd4e7963eb9a5dd6bcdc2a6790..7534eb253d7b942b8ff7fb959051b01b2a36fcbc 100644 (file)
@@ -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"
index 0965aa8b0bcb864fd2daf0cf3f3b8cf23ef526a4..65f41f677be59b55c4a9d81e3c3a6ab089d869ea 100644 (file)
@@ -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;