diff options
| author | Marek Polacek <polacek@redhat.com> | 2026-01-28 17:05:46 -0500 |
|---|---|---|
| committer | Marek Polacek <polacek@redhat.com> | 2026-01-30 08:31:43 -0500 |
| commit | f28f4ddcfd59015cc926e215dd53ad447f6bc10f (patch) | |
| tree | 418f3774a315807c0a68c81a0fab3d28d46fefa0 /gcc/testsuite | |
| parent | 35d45295f555a4970e98180f4a2f6099f345c363 (diff) | |
| download | gcc-master.zip gcc-master.tar.gz gcc-master.tar.bz2 | |
As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-January/705756.html>,
we should check TYPE_BEING_DEFINED along with COMPLETE_TYPE_P in
eval_define_aggregate. It seems that with this check added, we don't
need this code anymore:
if (c == type)
{
auto_diagnostic_group d;
error_at (loc, "%<define_aggregate%> evaluated from "
"%<consteval%> block enclosed by %qT being "
"defined", type);
//...
}
so I'm removing that in this patch.
gcc/cp/ChangeLog:
* reflect.cc (eval_define_aggregate): Also give an error when
TYPE_BEING_DEFINED is true for the first argument. Remove code
that did the same.
gcc/testsuite/ChangeLog:
* g++.dg/reflect/define_aggregate3.C: Adjust expected diagnostic.
* g++.dg/reflect/p2996-21.C: Likewise.
Reviewed-by: Jakub Jelinek <jakub@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/testsuite')
| -rw-r--r-- | gcc/testsuite/g++.dg/reflect/define_aggregate3.C | 16 | ||||
| -rw-r--r-- | gcc/testsuite/g++.dg/reflect/p2996-21.C | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/gcc/testsuite/g++.dg/reflect/define_aggregate3.C b/gcc/testsuite/g++.dg/reflect/define_aggregate3.C index db04a80..5951f7c 100644 --- a/gcc/testsuite/g++.dg/reflect/define_aggregate3.C +++ b/gcc/testsuite/g++.dg/reflect/define_aggregate3.C @@ -15,8 +15,8 @@ consteval bool foo () { return define_aggregate (^^S2, {}) == ^^S2; } const bool a = foo (); // { dg-error "call to consteval function 'foo\\\(\\\)' is not a constant expression" } struct S3 { - consteval { // { dg-message "'consteval' block defined here" } - define_aggregate (^^S3, {}); // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S3' being defined" } + consteval { + define_aggregate (^^S3, {}); // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S3. being defined" } } }; @@ -33,26 +33,26 @@ consteval { template <typename T> struct S5 { - consteval { // { dg-message "'consteval' block defined here" } - define_aggregate (^^S5 <T>, {}); // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S5<int>' being defined" } + consteval { + define_aggregate (^^S5 <T>, {}); // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S5<int>. being defined" } } }; S5 <int> s5; -consteval bool bar (info x) { return define_aggregate (x, {}) == x; } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S6' being defined" } +consteval bool bar (info x) { return define_aggregate (x, {}) == x; } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S6. being defined" } struct S6 { - consteval { // { dg-message "'consteval' block defined here" } + consteval { bar (^^S6); } }; -consteval bool baz (info x) { return define_aggregate (x, {}) == x; } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S7<char>' being defined" } +consteval bool baz (info x) { return define_aggregate (x, {}) == x; } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S7<char>. being defined" } template <typename T> struct S7 { - consteval { // { dg-message "'consteval' block defined here" } + consteval { baz (^^S7 <T>); } }; diff --git a/gcc/testsuite/g++.dg/reflect/p2996-21.C b/gcc/testsuite/g++.dg/reflect/p2996-21.C index 8a9f789..478be47 100644 --- a/gcc/testsuite/g++.dg/reflect/p2996-21.C +++ b/gcc/testsuite/g++.dg/reflect/p2996-21.C @@ -7,9 +7,9 @@ using namespace std::meta; struct S0 { - consteval { // { dg-message "'consteval' block defined here" } + consteval { std::meta::define_aggregate(^^S0, {}); // error: scope associated with S0 encloses the consteval block - } // { dg-error "'define_aggregate' evaluated from 'consteval' block enclosed by 'S0' being defined" "" { target *-*-* } .-1 } + } // { dg-error "first 'define_aggregate' argument is a reflection of a class type .S0. being defined" "" { target *-*-* } .-1 } }; struct S1; |
