26 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify=expected,precxx17,precxx20 %std_cxx98-14 %s2// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx17,precxx20 -std=c++17 %s3// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 %std_cxx20- %s4 5template<typename T, T Value> struct Constant;6// FIXME: bad location precxx20-error@-1 {{a non-type template parameter cannot have type 'float'}}7// expected-note@-2 {{template parameter is declared here}}8// cxx20-note@-3 {{template parameter is declared here}}9 10Constant<int, 5> *c1;11 12int x;13float f(int, double);14 15Constant<int&, x> *c2;16Constant<int*, &x> *c3;17Constant<float (*)(int, double), f> *c4;18Constant<float (*)(int, double), &f> *c5;19 20Constant<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)'}} \21 cxx17-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}} \22 cxx20-error {{value of type 'float (int, double)' is not implicitly convertible to 'float (*)(int, int)'}}23 24Constant<float, 0> *c7; // precxx20-note {{while substituting}} \25 cxx20-error {{conversion from 'int' to 'float' is not allowed in a converted constant expression}}26