aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-01-16 20:56:46 +1100
committerNathaniel Shead <nathanieloshead@gmail.com>2024-01-17 09:40:42 +1100
commitfe1649eea76f193732d22ec022a35326523eb37a (patch)
tree739eaebd7ad3655f3bbdffc647634d22db75ad2a /gcc/cp
parent7d397269753ca70256ce309b4d3081154e8c7a65 (diff)
downloadgcc-fe1649eea76f193732d22ec022a35326523eb37a.zip
gcc-fe1649eea76f193732d22ec022a35326523eb37a.tar.gz
gcc-fe1649eea76f193732d22ec022a35326523eb37a.tar.bz2
c++: Fix ENABLE_SCOPE_CHECKING printing
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. Additionally, the comment on 'explicit_spec_p' says that the flag is only valid if kind is 'sk_template_parms', so we rewrite the condition to be more obviously correct here. gcc/cp/ChangeLog: * name-lookup.h (enum scope_kind): Add 'sk_count'. * name-lookup.cc (cp_binding_level_descriptor): Add missing scope kinds. Add assertion that the list is up to date. Fix handling of explicit_spec_p. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/name-lookup.cc15
-rw-r--r--gcc/cp/name-lookup.h3
2 files changed, 14 insertions, 4 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index d827d33..15b5fba 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4464,14 +4464,23 @@ 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;
+ static_assert (ARRAY_SIZE (scope_kind_names) == sk_count,
+ "must keep names aligned with scope_kind enum");
+
+ scope_kind kind = scope->kind;
+ if (kind == sk_template_parms && scope->explicit_spec_p)
+ kind = sk_template_spec;
return scope_kind_names[kind];
}
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index 4f8454e..d237132 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -213,7 +213,8 @@ enum scope_kind {
explicit specialization is introduced by
"template <>", this scope is always empty. */
sk_transaction, /* A synchronized or atomic statement. */
- sk_omp /* An OpenMP structured block. */
+ sk_omp, /* An OpenMP structured block. */
+ sk_count /* Number of scope_kind enumerations. */
};
struct GTY(()) cp_class_binding {