1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 template<typename T, typename U = float> struct A { };
3 
4 typedef A<int> A_int;
5 
6 typedef float FLOAT;
7 
foo(A<int> * ptr,A<int> const * ptr2,A<int,double> * ptr3)8 A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) {
9   if (ptr)
10     return ptr; // okay
11   else if (ptr2)
12     return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}}
13   else {
14     return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}}
15   }
16 }
17 
18 template<int I> struct B;
19 
20 const int value = 12;
bar(B<(19)> * ptr1,B<(::value+7)> * ptr2,B<19-3> * ptr3)21 B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) {
22   if (ptr1)
23     return ptr1;
24   else if (ptr2)
25     return ptr2;
26   else
27     return ptr3; // expected-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}}
28 }
29 
30 typedef B<5> B5;
31 
32 
33 namespace N {
34   template<typename T> struct C {};
35 }
36 
37 N::C<int> c1;
38 typedef N::C<float> c2;
39 
40 // PR5655
41 template<typename T> struct Foo { }; // expected-note{{template is declared here}}
42 
f(void)43 void f(void) { Foo bar; } // expected-error{{use of class template 'Foo' requires template arguments}}
44 
45 // rdar://problem/8254267
46 template <typename T> class Party;
47 template <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}}
48