https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124241

chzn at mail dot ustc.edu.cn <chzn at mail dot ustc.edu.cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chzn at mail dot ustc.edu.cn

--- Comment #4 from chzn at mail dot ustc.edu.cn <chzn at mail dot ustc.edu.cn> 
---
as https://cppreference.com/cpp/language/union#Anonymous_unions says, "Members
of an anonymous union are injected in the enclosing scope".
I think we can treat such member as being in an equivalent scope.

--- a/gcc/cp/reflect.cc
+++ b/gcc/cp/reflect.cc
@@ -6667,6 +6667,17 @@ eval_is_accessible (location_t loc, const constexpr_ctx
*ctx, tree r,
        }
       else
        c = CP_DECL_CONTEXT (r);
+      if (ANON_AGGR_TYPE_P (c))
+        {
+          tree er = r;
+          while (ANON_AGGR_TYPE_P (c))
+            {
+              er = c;
+              c = CP_TYPE_CONTEXT (c);
+            }
+          if (eval_is_class_member (er) != boolean_true_node)
+            return boolean_true_node;
+        }
     }
   else if (kind == REFLECT_BASE)
     {


here is my patch:
https://gcc.gnu.org/pipermail/gcc-patches/2026-April/714787.html

Reply via email to