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