1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 23e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregortemplate<typename T, typename U = float> struct A { }; 355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 455f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregortypedef A<int> A_int; 555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor 63e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregortypedef float FLOAT; 73e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor 83e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas GregorA<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) { 955f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor if (ptr) 103e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor return ptr; // okay 1155f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor else if (ptr2) 122f69a816a0986caa24d8e4273a3f83420b05f707Chris Lattner return ptr2; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' with an lvalue of type 'const A<int> *'}} 1355f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor else { 1418ef5e28a9a2677f8b1dce1fb2638d66e0a1621fDouglas Gregor return ptr3; // expected-error{{cannot initialize return object of type 'A<int, FLOAT> *' with an lvalue of type 'A<int, double> *'}} 1555f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor } 1655f6b14230c94272efbbcdd89a92224c8db9f225Douglas Gregor} 173e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor 183e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregortemplate<int I> struct B; 193e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor 203e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregorconst int value = 12; 213e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas GregorB<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) { 223e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor if (ptr1) 233e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor return ptr1; 243e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor else if (ptr2) 253e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor return ptr2; 263e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor else 2718ef5e28a9a2677f8b1dce1fb2638d66e0a1621fDouglas Gregor return ptr3; // expected-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}} 283e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor} 293e00bad490f1bae8a2c60f934e7eb5dbb9752c5dDouglas Gregor 30a35b1d5f1d02c19d44d7a41b1971b97eefb79d41Douglas Gregortypedef B<5> B5; 319135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregor 329135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregor 339135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregornamespace N { 349135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregor template<typename T> struct C {}; 359135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregor} 369135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregor 379135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas GregorN::C<int> c1; 389135c72fd17bf313072fa12cfe66eb2437ef8e9dDouglas Gregortypedef N::C<float> c2; 399af2f52fbcb993350f54e57d498e7849ba29c75dDouglas Gregor 409af2f52fbcb993350f54e57d498e7849ba29c75dDouglas Gregor// PR5655 419af2f52fbcb993350f54e57d498e7849ba29c75dDouglas Gregortemplate<typename T> struct Foo { }; // expected-note{{template is declared here}} 429af2f52fbcb993350f54e57d498e7849ba29c75dDouglas Gregor 434b02dff7aebb98d2d60b2ff4d3fc86109213128cDavid Blaikievoid f(void) { Foo bar; } // expected-error{{use of class template 'Foo' requires template arguments}} 44207014eb2b372aa33721e86d90a8a586ba8dc8aeJohn McCall 45207014eb2b372aa33721e86d90a8a586ba8dc8aeJohn McCall// rdar://problem/8254267 46207014eb2b372aa33721e86d90a8a586ba8dc8aeJohn McCalltemplate <typename T> class Party; 47207014eb2b372aa33721e86d90a8a586ba8dc8aeJohn McCalltemplate <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}} 48