On 1/15/24 04:41, Nathaniel Shead wrote:
While working on another bug, I noticed the ENABLE_SCOPE_CHECKING macro
and thought to try it out. It caused selftest to ICE. This patch is a
minimal fix to get it working again.

Probably this should use a test to stop this regressing again in the
future the next time new scope-kinds are added, but given it's dependent
on a (almost certainly rarely-used) build-time macro I'm not sure
exactly how you would do that?

Or alternatively I could add a `sk_count` to the end of the scope kind
list and `static_assert` that the size of the descriptor list matches?

That sounds good.

(Also not sure if this would be appropriate for stage 4 or if it should
wait till next stage 1. I suppose this fixes a regression but I suspect
this has been broken for a very long time.)

I think it's OK now since it doesn't affect the normal codepath.

-- >8 --

The lists of scope kinds used by ENABLE_SCOPE_CHECKING don't seem to
have been updated in a long while, causing ICEs and confusing output.
This patch brings the list into line.

gcc/cp/ChangeLog:

        * name-lookup.cc (cp_binding_level_descriptor): Add missing
        scope kinds.

Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
---
  gcc/cp/name-lookup.cc | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index d827d337d3b..2e93ed183f1 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4464,11 +4464,16 @@ cp_binding_level_descriptor (cp_binding_level *scope)
      "try-scope",
      "catch-scope",
      "for-scope",
+    "cond-init-scope",
+    "stmt-expr-scope",
      "function-parameter-scope",
      "class-scope",
+    "enum-scope",
      "namespace-scope",
      "template-parameter-scope",
-    "template-explicit-spec-scope"
+    "template-explicit-spec-scope",
+    "transaction-scope",
+    "openmp-scope"
    };
    const scope_kind kind = scope->explicit_spec_p
      ? sk_template_spec : scope->kind;

Reply via email to