[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / instantiation-default-2.cpp
blob99c25000bcb0b0d3c7e12a675e0bda82cf3ec83e
1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17,precxx20 %std_cxx98-14 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17,precxx20 -std=c++17 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 %std_cxx20- %s
5 template<typename T, T Value> struct Constant; // precxx17-note{{template parameter is declared here}} \
6 // FIXME: bad location precxx20-error{{a non-type template parameter cannot have type 'float'}}
8 Constant<int, 5> *c1;
10 int x;
11 float f(int, double);
13 Constant<int&, x> *c2;
14 Constant<int*, &x> *c3;
15 Constant<float (*)(int, double), f> *c4;
16 Constant<float (*)(int, double), &f> *c5;
18 Constant<float (*)(int, int), f> *c6; // precxx17-error {{non-type template argument of type 'float (int, double)' cannot be converted to a value of type 'float (*)(int, int)'}} \
19 cxx17-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}} \
20 cxx20-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}}
22 Constant<float, 0> *c7; // precxx20-note {{while substituting}} \
23 cxx20-error {{conversion from 'int' to 'float' is not allowed in a converted constant expression}}