Hi! The following patch adds testcases for 5 DRs. In the DR2475, DR2530 and DR2691 my understanding is we already implement the desired behavior, in DR2478 partially (I've added 2 dg-bogus there, I think we inherit rather than overwrite DECL_DECLARED_CONSTINIT_P for explicit specialization somewhere, still far better than clang++) and DR2673 on the other side the DR was to codify the clang++ behavior rather than GCC.
Not 100% sure if it is better to commit the 2 with dg-bogus or just wait until the actual fixes are implemented. BTW, I've noticed register_specialization does: FOR_EACH_CLONE (clone, fn) { DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn); DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); DECL_DELETED_FN (clone) = DECL_DELETED_FN (fn); } but not e.g. constexpr/consteval, have tried to cover that in a testcase but haven't managed to do so. Tested on x86_64-linux with GXX_TESTSUITE_STDS=98,11,14,17,20,2b make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} dg.exp=DRs/*.C' ok for trunk (or ok just for the 1st, 3rd and 5th testcase)? 2023-02-14 Jakub Jelinek <ja...@redhat.com> * g++.dg/DRs/dr2475.C: New test. * g++.dg/DRs/dr2478.C: New test. * g++.dg/DRs/dr2530.C: New test. * g++.dg/DRs/dr2673.C: New test. * g++.dg/DRs/dr2691.C: New test. --- gcc/testsuite/g++.dg/DRs/dr2475.C.jj 2023-02-14 10:14:18.300920099 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2475.C 2023-02-14 11:24:38.676314439 +0100 @@ -0,0 +1,6 @@ +// DR 2475 - Object declarations of type cv void +// { dg-do compile } + +int f(), x; +extern void g(), + y; // { dg-error "variable or field 'y' declared void" } --- gcc/testsuite/g++.dg/DRs/dr2478.C.jj 2023-02-14 10:23:35.487795016 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2478.C 2023-02-14 11:24:49.092162197 +0100 @@ -0,0 +1,74 @@ +// DR 2478 - Properties of explicit specializations of implicitly-instantiated class templates +// { dg-do compile { target c++20 } } + +template <typename T> +struct S { + int foo () { return 0; } + constexpr int bar () { return 0; } + int baz () { return 0; } + consteval int qux () { return 0; } + constexpr S () {} + static constinit T x; + static T y; +}; + +template <typename T> +T S<T>::x = S<T> ().foo (); // { dg-error "'constinit' variable 'S<char>::x' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } + +template <typename T> +T S<T>::y = S<T> ().foo (); + +template <> +constexpr int +S<int>::foo () +{ + return 0; +} + +template <> +int +S<int>::bar () +{ + return 0; +} + +template <> +consteval int +S<char>::baz () +{ + return 0; +} + +template <> +int +S<char>::qux () +{ + return 0; +} + +template <> +long S<long>::x = S<long> ().foo (); // { dg-bogus "'constinit' variable 'S<long int>::x' does not have a constant initializer" "" { xfail *-*-* } } + // { dg-bogus "call to non-'constexpr' function" "" { xfail *-*-* } .-1 } + +template <> +constinit long S<long>::y = S<long> ().foo (); // { dg-error "'constinit' variable 'S<long int>::y' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } + +constinit auto a = S<char> ().foo (); // { dg-error "'constinit' variable 'a' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto b = S<char> ().bar (); +constinit auto c = S<int> ().foo (); +constinit auto d = S<int> ().bar (); // { dg-error "'constinit' variable 'd' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto e = S<char> ().baz (); +constinit auto f = S<char> ().qux (); // { dg-error "'constinit' variable 'f' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto g = S<int> ().baz (); // { dg-error "'constinit' variable 'g' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto h = S<int> ().qux (); +auto i = S<char>::x; +auto j = S<int>::x; +auto k = S<long>::x; +auto l = S<char>::y; +auto m = S<int>::y; --- gcc/testsuite/g++.dg/DRs/dr2530.C.jj 2023-02-14 11:23:14.306547587 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2530.C 2023-02-14 11:25:58.557146894 +0100 @@ -0,0 +1,5 @@ +// DR 2530 - Multiple definitions of enumerators +// { dg-do compile } + +enum E { e, e }; // { dg-error "redefinition of 'e'" } +enum F { f = 0, f = 0 }; // { dg-error "redefinition of 'f'" } --- gcc/testsuite/g++.dg/DRs/dr2673.C.jj 2023-02-14 11:38:15.030394220 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2673.C 2023-02-14 11:46:00.262604342 +0100 @@ -0,0 +1,24 @@ +// DR 2673 - User-declared spaceship vs. built-in operators +// { dg-do compile { target c++20 } } + +#include <compare> + +enum class E : int { E1, E2 }; +enum class F : int { F1, F2 }; + +constexpr auto +operator<=> (E lhs, E rhs) +{ + return (int) rhs <=> (int) lhs; +} + +constexpr bool +operator== (F lhs, F rhs) +{ + return (int) lhs != (int) rhs; +} + +static_assert ((E::E1 <=> E::E2) == (1 <=> 0)); +static_assert (E::E1 > E::E2); // { dg-bogus "static assertion failed" "" { xfail *-*-* } } +static_assert (F::F1 == F::F2); +static_assert (!(F::F1 != F::F2)); // { dg-bogus "static assertion failed" "" { xfail *-*-* } } --- gcc/testsuite/g++.dg/DRs/dr2691.C.jj 2023-02-14 11:48:35.841335492 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2691.C 2023-02-14 11:57:21.538669133 +0100 @@ -0,0 +1,15 @@ +// DR 2691 - hexadecimal-escape-sequence is too greedy +// { dg-do run { target c++11 } } +// { dg-require-effective-target wchar } +// { dg-options "-pedantic" } + +extern "C" void abort (); + +const char32_t *a = U"\x{20}ab"; // { dg-warning "delimited escape sequences are only valid in" "" { target c++20_down } } + +int +main () +{ + if (a[0] != U'\x20' || a[1] != U'a' || a[2] != U'b' || a[3] != U'\0') + abort (); +} Jakub