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