P1907R1 made various adjustments to non-type template parameters, notably introducing the notion of "structural type". I implemented an early version of that specification in r10-4426, but it was adjusted in the final paper to allow more. This patch implements allowing template parameters of floating-point type; still to be implemented are unions and subobjects. gcc/cp/ChangeLog: * pt.c (convert_nontype_argument): Handle REAL_TYPE. (invalid_nontype_parm_type_p): Allow all structural types. * tree.c (structural_type_p): Use SCALAR_TYPE_P. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/pr81246.C: No error in C++20. * g++.dg/cpp0x/variadic74.C: No error in C++20. * g++.dg/cpp1z/nontype-auto3.C: No error in C++20. * g++.dg/template/crash106.C: No error in C++20. * g++.dg/template/crash119.C: No error in C++20. * g++.dg/template/nontype12.C: No error in C++20. * g++.dg/template/void3.C: Don't require follow-on message. * g++.dg/template/void7.C: Don't require follow-on message. * g++.dg/template/void9.C: Don't require follow-on message.
27 lines
733 B
C
27 lines
733 B
C
// { dg-do compile { target c++11 } }
|
|
template <class... Types> class A
|
|
{
|
|
public:
|
|
template <Types... Values> class X { /* ... */ }; // { dg-error "not a valid type for a template non-type parameter" "" { target c++17_down } }
|
|
};
|
|
|
|
template<class... Types> class B
|
|
{
|
|
public:
|
|
template <Types*... Values> class X {
|
|
typename A<Types*...>::template X<Values...> foo;
|
|
};
|
|
};
|
|
|
|
int i;
|
|
float f;
|
|
|
|
A<int*, float*>::X<&i, &f> apple1;
|
|
B<int, float>::X<&i, &f> banana1;
|
|
|
|
A<int*, float*>::X<&i> apple2; // { dg-error "wrong number of template arguments" "wrong number" }
|
|
A<int*, float*>::X<&i, &f, &f> apple3; // { dg-error "wrong number of template arguments" "wrong number" }
|
|
A<int, float> apple4;
|
|
|
|
// { dg-prune-output "provided for" }
|