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
{ };
10 A
<int, FLOAT
> *foo(A
<int> *ptr
, A
<int> const *ptr2
, A
<int, double> *ptr3
) {
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> *'}}
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
;
25 B
<17 + 2> *bar(B
<(19)> *ptr1
, B
< (::value
+ 7) > *ptr2
, B
<19 - 3> *ptr3
) {
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>}}
39 template<typename T> struct C {};
43 typedef N::C<float> c2;
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'}}