blob: 57159998fe1912246b5501d71fab150ca3df2efa [file] [log] [blame]
Richard Smith8f8f05c2013-06-24 04:45:28 +00001// RUN: rm -rf %t
Rafael Espindola925213b2013-07-04 16:16:58 +00002// 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 Smith8f8f05c2013-06-24 04:45:28 +00004// 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 Smithbf78e642013-06-24 22:51:00 +00009template<typename, char> struct Tmpl_T_C {};
10template<typename, int, int> struct Tmpl_T_I_I {};
11
12template<typename A, typename B, A> struct Tmpl_T_T_A {};
13template<typename A, typename B, B> struct Tmpl_T_T_B {};
14
Richard Smith8f8f05c2013-06-24 04:45:28 +000015void g() {
16 f(0);
17 f<double>(1.0);
18 f<int>();
19 f(); // expected-error {{no matching function}}
Richard Smith5de91b52013-06-25 01:25:15 +000020 // 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 Smith8f8f05c2013-06-24 04:45:28 +000022
23 N::f(0);
24 N::f<double>(1.0);
25 N::f<int>();
26 N::f(); // expected-error {{no matching function}}
Richard Smith5de91b52013-06-25 01:25:15 +000027 // expected-note@Inputs/cxx-templates-a.h:6 {{couldn't infer template argument}}
28 // expected-note@Inputs/cxx-templates-a.h:7 {{requires 1 argument, but 0 were provided}}
Richard Smithbf78e642013-06-24 22:51:00 +000029
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 Smith5de91b52013-06-25 01:25:15 +000034 // 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 Smithbf78e642013-06-24 22:51:00 +000036
37 template_param_kinds_2<Tmpl_T_I_I>(); // expected-error {{ambiguous}}
Richard Smith5de91b52013-06-25 01:25:15 +000038 // expected-note@Inputs/cxx-templates-a.h:11 {{candidate}}
39 // expected-note@Inputs/cxx-templates-b.h:11 {{candidate}}
Richard Smithbf78e642013-06-24 22:51:00 +000040
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 Smith5de91b52013-06-25 01:25:15 +000044 // expected-note@Inputs/cxx-templates-a.h:12 {{candidate}}
45 // expected-note@Inputs/cxx-templates-b.h:12 {{candidate}}
Richard Smithbf78e642013-06-24 22:51:00 +000046 template_param_kinds_3<Tmpl_T_T_B>(); // expected-error {{ambiguous}}
Richard Smith5de91b52013-06-25 01:25:15 +000047 // expected-note@Inputs/cxx-templates-a.h:12 {{candidate}}
48 // expected-note@Inputs/cxx-templates-b.h:12 {{candidate}}
Richard Smith8f8f05c2013-06-24 04:45:28 +000049}
50
Richard Smith5de91b52013-06-25 01:25:15 +000051@import cxx_templates_common;
52
53typedef SomeTemplate<int*> SomeTemplateIntPtr;
54typedef SomeTemplate<int&> SomeTemplateIntRef;
55SomeTemplate<char*> some_template_char_ptr;
56SomeTemplate<char&> some_template_char_ref;
57
Richard Smith8f8f05c2013-06-24 04:45:28 +000058// FIXME: There should only be two 'f's here.
59// CHECK-GLOBAL: DeclarationName 'f'
60// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
61// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
62// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
Richard Smith8f8f05c2013-06-24 04:45:28 +000063// CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'
64
65// FIXME: There should only be two 'f's here.
66// CHECK-NAMESPACE-N: DeclarationName 'f'
67// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f'
68// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f'
69// CHECK-NAMESPACE-N-NEXT: |-FunctionTemplate {{.*}} 'f'
70// CHECK-NAMESPACE-N-NEXT: `-FunctionTemplate {{.*}} 'f'