diff options
Diffstat (limited to 'test/Modules')
-rw-r--r-- | test/Modules/Inputs/module.map | 12 | ||||
-rw-r--r-- | test/Modules/Inputs/redecl-merge-bottom.h | 8 | ||||
-rw-r--r-- | test/Modules/Inputs/redecl-merge-left.h | 21 | ||||
-rw-r--r-- | test/Modules/Inputs/redecl-merge-right.h | 20 | ||||
-rw-r--r-- | test/Modules/Inputs/redecl-merge-top.h | 9 | ||||
-rw-r--r-- | test/Modules/Inputs/templates-left.h | 27 | ||||
-rw-r--r-- | test/Modules/Inputs/templates-right.h | 25 | ||||
-rw-r--r-- | test/Modules/Inputs/templates-top.h | 6 | ||||
-rw-r--r-- | test/Modules/redecl-merge.m | 26 | ||||
-rw-r--r-- | test/Modules/templates.mm | 28 |
10 files changed, 104 insertions, 78 deletions
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 79056cb518..9044922799 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -78,6 +78,18 @@ module namespaces_right { header "namespaces-right.h" export * } +module templates_top { + header "templates-top.h" + export * +} +module templates_left { + header "templates-left.h" + export * +} +module templates_right { + header "templates-right.h" + export * +} module MethodPoolA { header "MethodPoolA.h" } diff --git a/test/Modules/Inputs/redecl-merge-bottom.h b/test/Modules/Inputs/redecl-merge-bottom.h index 40a9404abf..cfea7dc87d 100644 --- a/test/Modules/Inputs/redecl-merge-bottom.h +++ b/test/Modules/Inputs/redecl-merge-bottom.h @@ -18,11 +18,3 @@ struct S3; void refers_to_C4(C4*); -#ifdef __cplusplus -template<typename T> class Vector; - -template<typename T> class Vector; - -template<typename T> class Vector; -#endif - diff --git a/test/Modules/Inputs/redecl-merge-left.h b/test/Modules/Inputs/redecl-merge-left.h index 1f5da4f2e2..ee794ff320 100644 --- a/test/Modules/Inputs/redecl-merge-left.h +++ b/test/Modules/Inputs/redecl-merge-left.h @@ -78,27 +78,6 @@ extern float var2; extern double var3; -#ifdef __cplusplus -template<typename T> class Vector; - -template<typename T> class Vector; - -template<typename T> class List; -template<> class List<bool> { -public: - void push_back(int); -}; -namespace N { - template<typename T> class Set; -} -namespace N { - template<typename T> class Set { - public: - void insert(T); - }; -} -#endif - // Make sure this doesn't introduce an ambiguity-creating 'id' at the // top level. typedef void funcptr_with_id(int id); diff --git a/test/Modules/Inputs/redecl-merge-right.h b/test/Modules/Inputs/redecl-merge-right.h index 2e05c035c5..f62020f205 100644 --- a/test/Modules/Inputs/redecl-merge-right.h +++ b/test/Modules/Inputs/redecl-merge-right.h @@ -78,26 +78,6 @@ extern int var2; static double var3; -#ifdef __cplusplus -template<typename T> class Vector { -public: - void push_back(const T&); -}; - -template<typename T> class List; -template<> class List<bool> { -public: - void push_back(int); -}; - -namespace N { - template<typename T> class Set { - public: - void insert(T); - }; -} -#endif - int ONE; @__experimental_modules_import redecl_merge_top.Explicit; const int one = ONE; diff --git a/test/Modules/Inputs/redecl-merge-top.h b/test/Modules/Inputs/redecl-merge-top.h index 7053936b2c..25456deb28 100644 --- a/test/Modules/Inputs/redecl-merge-top.h +++ b/test/Modules/Inputs/redecl-merge-top.h @@ -14,12 +14,3 @@ struct S1; struct S2; struct S2; - -#ifdef __cplusplus -template<typename T> class Vector; - -template<typename T> class List { -public: - void push_back(T); -}; -#endif diff --git a/test/Modules/Inputs/templates-left.h b/test/Modules/Inputs/templates-left.h new file mode 100644 index 0000000000..7f50cd4c4f --- /dev/null +++ b/test/Modules/Inputs/templates-left.h @@ -0,0 +1,27 @@ +@__experimental_modules_import templates_top; + +template<typename T> class Vector; + +template<typename T> class Vector; + +template<typename T> class List; +template<> class List<bool> { +public: + void push_back(int); +}; +namespace N { + template<typename T> class Set; +} +namespace N { + template<typename T> class Set { + public: + void insert(T); + }; +} + +template <typename T> +void pendingInstantiation(T) {} +void triggerPendingInstantiation() { + pendingInstantiation(12); + pendingInstantiation(42.); +} diff --git a/test/Modules/Inputs/templates-right.h b/test/Modules/Inputs/templates-right.h new file mode 100644 index 0000000000..f5487fb0e1 --- /dev/null +++ b/test/Modules/Inputs/templates-right.h @@ -0,0 +1,25 @@ +@__experimental_modules_import templates_top; + +template<typename T> class Vector { +public: + void push_back(const T&); +}; + +template<typename T> class List; +template<> class List<bool> { +public: + void push_back(int); +}; + +namespace N { + template<typename T> class Set { + public: + void insert(T); + }; +} + +template <typename T> +void pendingInstantiation(T) {} +void triggerPendingInstantiationToo() { + pendingInstantiation(12); +} diff --git a/test/Modules/Inputs/templates-top.h b/test/Modules/Inputs/templates-top.h new file mode 100644 index 0000000000..80ecf23ea4 --- /dev/null +++ b/test/Modules/Inputs/templates-top.h @@ -0,0 +1,6 @@ +template<typename T> class Vector; + +template<typename T> class List { +public: + void push_back(T); +}; diff --git a/test/Modules/redecl-merge.m b/test/Modules/redecl-merge.m index 96b0b47565..d7224149a2 100644 --- a/test/Modules/redecl-merge.m +++ b/test/Modules/redecl-merge.m @@ -1,6 +1,5 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class -// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class @class C2; @class C3; @class C3; @@ -57,26 +56,26 @@ void testTagMerge() { void testTypedefMerge(int i, double d) { T1 *ip = &i; - // in other file: expected-note{{candidate found by name lookup is 'T2'}} // FIXME: Typedefs aren't actually merged in the sense of other merges, because // we should only merge them when the types are identical. - // in other file: expected-note{{candidate found by name lookup is 'T2'}} - // in other file: expected-note{{candidate function}} + // in other file: expected-note@60{{candidate found by name lookup is 'T2'}} + // in other file: expected-note@63{{candidate found by name lookup is 'T2'}} T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}} } void testFuncMerge(int i) { func0(i); - // in other file: expected-note{{candidate function}} func1(i); + // in other file: expected-note@64{{candidate function}} + // in other file: expected-note@70{{candidate function}} func2(i); // expected-error{{call to 'func2' is ambiguous}} } void testVarMerge(int i) { var1 = i; - // in other files: expected-note 2{{candidate found by name lookup is 'var2'}} + // in other files: expected-note@77 2{{candidate found by name lookup is 'var2'}} var2 = i; // expected-error{{reference to 'var2' is ambiguous}} - // in other files: expected-note 2{{candidate found by name lookup is 'var3'}} + // in other files: expected-note@79 2{{candidate found by name lookup is 'var3'}} var3 = i; // expected-error{{reference to 'var3' is ambiguous}} } @@ -146,19 +145,6 @@ void g(A *a) { id<P4> p4; id<P3> p3; -#ifdef __cplusplus -void testVector() { - Vector<int> vec_int; - vec_int.push_back(0); - - List<bool> list_bool; - list_bool.push_back(false); - - N::Set<char> set_char; - set_char.insert('A'); -} -#endif - // Make sure we don't get conflicts with 'id'. funcptr_with_id fid; id id_global; diff --git a/test/Modules/templates.mm b/test/Modules/templates.mm new file mode 100644 index 0000000000..a9b45913c7 --- /dev/null +++ b/test/Modules/templates.mm @@ -0,0 +1,28 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs -verify %s -Wno-objc-root-class +// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | grep pendingInstantiation | FileCheck %s + +@__experimental_modules_import templates_left; +@__experimental_modules_import templates_right; + + +void testTemplateClasses() { + Vector<int> vec_int; + vec_int.push_back(0); + + List<bool> list_bool; + list_bool.push_back(false); + + N::Set<char> set_char; + set_char.insert('A'); +} + +void testPendingInstantiations() { + // CHECK: call + // CHECK: call + // CHECK: {{define .*pendingInstantiation.*[(]i}} + // CHECK: {{define .*pendingInstantiation.*[(]double}} + // CHECK: call + triggerPendingInstantiation(); + triggerPendingInstantiationToo(); +} |