On 5/11/26 4:26 AM, Torbjorn SVENSSON wrote:
Hi,

In r16-8662-g2cdd7831e31601, a new test was added that experience the same kind of issue that was addressed in this patch.

The following snippet allows the new test to work the same way as for the other 2 tests:

diff --git a/gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C b/ gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C
index 044a2a0d2a6..b3e01f911ec 100644
--- a/gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C
+++ b/gcc/testsuite/g++.dg/reflect/reflect_constant_array11.C
@@ -11,7 +11,7 @@ using namespace std::meta;
  struct A { int a, b; mutable int c; };
  constexpr A aa[2] = { { 1, 2, 3 }, { 4, 5, 6 } };
  constexpr auto a = reflect_constant_array (aa);
-// { dg-error "'reflect_constant_array' argument with 'std::ranges::range_value_t<const A \\\[2\\\]>' \\\{aka 'A'\\\} which is not a structural type" "" { target *-*-* } .-1 } +// { dg-error "'reflect_constant_array' argument with 'std::ranges::range_value_t<const A \\\[2\\\]>' \\\{aka '(A| std::iter_value_t<const A\\\*>)'\\\} which is not a structural type" "" { target *-*-* } .-1 }  struct B { constexpr B (int x, int y) : a (x), b (y) {} constexpr ~B () {} B (const B &) = delete; int a, b; };
  constexpr B b[2][2] = { { { 1, 2 }, { 2, 3 } }, { { 3, 4 }, { 4, 5 } } };
  constexpr auto c = reflect_constant_array (b);


Is this a feasible route to go or is there some work to be done in the compiler to avoid the 2 different error messages?

Does this (untested) patch help?

Jason
From 616260c496bf0a9bf608f5c4e73d0b2de1ab77d2 Mon Sep 17 00:00:00 2001
From: Jason Merrill <[email protected]>
Date: Mon, 11 May 2026 11:55:06 -0400
Subject: [PATCH] c-family: look through non-user-facing typedef
To: [email protected]

gcc/c-family/ChangeLog:

	* c-common.cc (user_facing_original_type_p): Recurse.
---
 gcc/c-family/c-common.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 2bf71e54045..874530f065d 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -9066,6 +9066,9 @@ user_facing_original_type_p (const_tree type)
     if (!name_reserved_for_implementation_p (IDENTIFIER_POINTER (orig_id)))
       return true;
 
+  if (typedef_variant_p (orig_type))
+    return user_facing_original_type_p (orig_type);
+
   switch (TREE_CODE (orig_type))
     {
     /* Don't look through to an anonymous vector type, since the syntax
-- 
2.54.0

Reply via email to