[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / class-template-id.cpp
blob0752800d04084e4f527a6198990a627b867bab26
1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23,precxx17 %std_cxx98-14 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx23,cxx17 %std_cxx17-20 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17,cxx23 %std_cxx23- %s
4 template<typename T, typename U = float> struct A { };
6 typedef A<int> A_int;
8 typedef float FLOAT;
10 A<int, FLOAT> *foo(A<int> *ptr, A<int> const *ptr2, A<int, double> *ptr3) {
11 if (ptr)
12 return ptr; // okay
13 else if (ptr2)
14 return ptr2; // precxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'const A<int> *'}} \
15 cxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an rvalue of type 'const A<int> *'}}
16 else {
17 return ptr3; // precxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an lvalue of type 'A<int, double> *'}} \
18 cxx23-error{{cannot initialize return object of type 'A<int, FLOAT> *' (aka 'A<int, float> *') with an rvalue of type 'A<int, double> *'}}
22 template<int I> struct B;
24 const int value = 12;
25 B<17 + 2> *bar(B<(19)> *ptr1, B< (::value + 7) > *ptr2, B<19 - 3> *ptr3) {
26 if (ptr1)
27 return ptr1;
28 else if (ptr2)
29 return ptr2;
30 else
31 return ptr3; // precxx23-error{{cannot initialize return object of type 'B<17 + 2> *' with an lvalue of type 'B<19 - 3>}} \
32 cxx23-error{{cannot initialize return object of type 'B<17 + 2> *' with an rvalue of type 'B<19 - 3>}}
35 typedef B<5> B5;
38 namespace N {
39 template<typename T> struct C {};
42 N::C<int> c1;
43 typedef N::C<float> c2;
45 // PR5655
46 template<typename T> struct Foo { }; // precxx17-note {{template is declared here}} \
47 cxx17-note {{candidate template ignored: couldn't infer template argument 'T'}} \
48 cxx17-note {{candidate function template not viable: requires 1 argument, but 0 were provided}}
50 void f(void) { Foo bar; } // precxx17-error {{use of class template 'Foo' requires template arguments}} \
51 cxx17-error {{no viable constructor or deduction guide for deduction of template arguments of 'Foo'}}
53 // rdar://problem/8254267
54 template <typename T> class Party;
55 template <> class Party<T> { friend struct Party<>; }; // expected-error {{use of undeclared identifier 'T'}}