Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 1 | // RUN: rm -rf %t |
Rafael Espindola | 925213b | 2013-07-04 16:16:58 +0000 | [diff] [blame] | 2 | // RUN: not %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups | FileCheck %s --check-prefix=CHECK-GLOBAL |
| 3 | // RUN: not %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter N | FileCheck %s --check-prefix=CHECK-NAMESPACE-N |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -x objective-c++ -fmodules -fmodules-cache-path=%t -I %S/Inputs %s -verify -std=c++11 |
| 5 | |
| 6 | @import cxx_templates_a; |
| 7 | @import cxx_templates_b; |
| 8 | |
Richard Smith | bf78e64 | 2013-06-24 22:51:00 +0000 | [diff] [blame] | 9 | template<typename, char> struct Tmpl_T_C {}; |
| 10 | template<typename, int, int> struct Tmpl_T_I_I {}; |
| 11 | |
| 12 | template<typename A, typename B, A> struct Tmpl_T_T_A {}; |
| 13 | template<typename A, typename B, B> struct Tmpl_T_T_B {}; |
| 14 | |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 15 | void g() { |
| 16 | f(0); |
| 17 | f<double>(1.0); |
| 18 | f<int>(); |
| 19 | f(); // expected-error {{no matching function}} |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 20 | // expected-note@Inputs/cxx-templates-b.h:3 {{couldn't infer template argument}} |
| 21 | // expected-note@Inputs/cxx-templates-b.h:4 {{requires single argument}} |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 22 | |
| 23 | N::f(0); |
| 24 | N::f<double>(1.0); |
| 25 | N::f<int>(); |
| 26 | N::f(); // expected-error {{no matching function}} |
Richard Smith | 0e5d7b8 | 2013-07-25 23:08:39 +0000 | [diff] [blame^] | 27 | // expected-note@Inputs/cxx-templates-b.h:6 {{couldn't infer template argument}} |
| 28 | // expected-note@Inputs/cxx-templates-b.h:7 {{requires single argument 't'}} |
Richard Smith | bf78e64 | 2013-06-24 22:51:00 +0000 | [diff] [blame] | 29 | |
| 30 | template_param_kinds_1<0>(); // ok, from cxx-templates-a.h |
| 31 | template_param_kinds_1<int>(); // ok, from cxx-templates-b.h |
| 32 | |
| 33 | template_param_kinds_2<Tmpl_T_C>(); // expected-error {{no matching function}} |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 34 | // expected-note@Inputs/cxx-templates-a.h:11 {{invalid explicitly-specified argument}} |
| 35 | // expected-note@Inputs/cxx-templates-b.h:11 {{invalid explicitly-specified argument}} |
Richard Smith | bf78e64 | 2013-06-24 22:51:00 +0000 | [diff] [blame] | 36 | |
| 37 | template_param_kinds_2<Tmpl_T_I_I>(); // expected-error {{ambiguous}} |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 38 | // expected-note@Inputs/cxx-templates-a.h:11 {{candidate}} |
| 39 | // expected-note@Inputs/cxx-templates-b.h:11 {{candidate}} |
Richard Smith | bf78e64 | 2013-06-24 22:51:00 +0000 | [diff] [blame] | 40 | |
| 41 | // FIXME: This should be valid, but we incorrectly match the template template |
| 42 | // argument against both template template parameters. |
| 43 | template_param_kinds_3<Tmpl_T_T_A>(); // expected-error {{ambiguous}} |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 44 | // expected-note@Inputs/cxx-templates-a.h:12 {{candidate}} |
| 45 | // expected-note@Inputs/cxx-templates-b.h:12 {{candidate}} |
Richard Smith | bf78e64 | 2013-06-24 22:51:00 +0000 | [diff] [blame] | 46 | template_param_kinds_3<Tmpl_T_T_B>(); // expected-error {{ambiguous}} |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 47 | // expected-note@Inputs/cxx-templates-a.h:12 {{candidate}} |
| 48 | // expected-note@Inputs/cxx-templates-b.h:12 {{candidate}} |
Richard Smith | 0e5d7b8 | 2013-07-25 23:08:39 +0000 | [diff] [blame^] | 49 | |
| 50 | // Trigger the instantiation of a template in 'a' that uses a type defined in |
| 51 | // 'common'. That type is not visible here. |
| 52 | PerformDelayedLookup(defined_in_common); |
| 53 | |
| 54 | // Trigger the instantiation of a template in 'b' that uses a type defined in |
| 55 | // 'b_impl'. That type is not visible here. |
| 56 | UseDefinedInBImpl<int>(); |
| 57 | |
| 58 | // Trigger the instantiation of a template in 'a' that uses a type defined in |
| 59 | // 'b_impl', via a template defined in 'b'. Since the type is visible from |
| 60 | // within 'b', the instantiation succeeds. |
| 61 | UseDefinedInBImplIndirectly(defined_in_b_impl); |
| 62 | |
| 63 | // Trigger the instantiation of a template in 'a' that uses a type defined in |
| 64 | // 'b_impl'. That type is not visible here, nor in 'a'. This fails; there is |
| 65 | // no reason why DefinedInBImpl should be visible here. |
| 66 | // expected-error@Inputs/cxx-templates-a.h:19 {{definition of 'DefinedInBImpl' must be imported}} |
| 67 | // expected-note@Inputs/cxx-templates-b-impl.h:1 {{definition is here}} |
| 68 | PerformDelayedLookup(defined_in_b_impl); // expected-note {{in instantiation of}} |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Richard Smith | 5de91b5 | 2013-06-25 01:25:15 +0000 | [diff] [blame] | 71 | @import cxx_templates_common; |
| 72 | |
| 73 | typedef SomeTemplate<int*> SomeTemplateIntPtr; |
| 74 | typedef SomeTemplate<int&> SomeTemplateIntRef; |
| 75 | SomeTemplate<char*> some_template_char_ptr; |
| 76 | SomeTemplate<char&> some_template_char_ref; |
| 77 | |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 78 | // FIXME: There should only be two 'f's here. |
| 79 | // CHECK-GLOBAL: DeclarationName 'f' |
| 80 | // CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' |
| 81 | // CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' |
| 82 | // CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f' |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 83 | // CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f' |
| 84 | |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 85 | // CHECK-NAMESPACE-N: DeclarationName 'f' |
| 86 | // CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f' |
Richard Smith | 8f8f05c | 2013-06-24 04:45:28 +0000 | [diff] [blame] | 87 | // CHECK-NAMESPACE-N-NEXT: `-FunctionTemplate {{.*}} 'f' |