p5.cpp revision be0ee875d8a91c031a085cbbd73ad9e8dc1aa8ff
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3template<typename T> inline void f(T) { } 4template void f(int); // expected-note{{previous explicit instantiation}} 5template void f(int); // expected-error{{duplicate explicit instantiation}} 6 7template<typename T> 8struct X0 { 9 union Inner { }; 10 11 void f(T) { } 12 13 static T value; 14}; 15 16template<typename T> 17T X0<T>::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}} 18 19template struct X0<int>; // expected-note{{previous explicit instantiation}} \ 20 expected-note{{requested here}} 21template struct X0<int>; // expected-error{{duplicate explicit instantiation}} 22 23template void X0<float>::f(float); // expected-note{{previous explicit instantiation}} 24template void X0<float>::f(float); // expected-error{{duplicate explicit instantiation}} 25 26template union X0<float>::Inner; // expected-note{{previous explicit instantiation}} 27template union X0<float>::Inner; // expected-error{{duplicate explicit instantiation}} 28 29template float X0<float>::value; // expected-note{{previous explicit instantiation}} 30template float X0<float>::value; // expected-error{{duplicate explicit instantiation}} 31 32// Make sure that we don't get tricked by redeclarations of nested classes. 33namespace NestedClassRedecls { 34 template<typename T> 35 struct X { 36 struct Nested; 37 friend struct Nested; 38 39 struct Nested { 40 Nested() {} 41 } nested; 42 }; 43 44 X<int> xi; 45 46 template struct X<int>; 47} 48