PR c++/96442: Improved error recovery in enumerations.
This patch is a revised fix for PR c++/96442 providing a cleaner solution, setting ENUM_UNDERLYING_TYPE to integer_type_node when issuing an error, so that this invariant holds during the parser's error recovery. 2022-06-07 Roger Sayle <roger@nextmovesoftware.com> gcc/cp/ChangeLog PR c++/96442 * decl.cc (start_enum): When emitting a "must be integral" error, set ENUM_UNDERLYING_TYPE to integer_type_node, to avoid an ICE downstream in build_enumeration. gcc/testsuite/ChangeLog PR c++/96442 * g++.dg/parse/pr96442.C: New test case.
This commit is contained in:
parent
c4320bde42
commit
6dd194e2ce
@ -16314,8 +16314,11 @@ start_enum (tree name, tree enumtype, tree underlying_type,
|
||||
else if (dependent_type_p (underlying_type))
|
||||
ENUM_UNDERLYING_TYPE (enumtype) = underlying_type;
|
||||
else
|
||||
error ("underlying type %qT of %qT must be an integral type",
|
||||
underlying_type, enumtype);
|
||||
{
|
||||
error ("underlying type %qT of %qT must be an integral type",
|
||||
underlying_type, enumtype);
|
||||
ENUM_UNDERLYING_TYPE (enumtype) = integer_type_node;
|
||||
}
|
||||
}
|
||||
|
||||
/* If into a template class, the returned enum is always the first
|
||||
|
6
gcc/testsuite/g++.dg/parse/pr96442.C
Normal file
6
gcc/testsuite/g++.dg/parse/pr96442.C
Normal file
@ -0,0 +1,6 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2" } */
|
||||
enum struct a : struct {};
|
||||
template <class b> enum class a : class c{};
|
||||
enum struct a {b};
|
||||
// { dg-excess-errors "" }
|
Loading…
Reference in New Issue
Block a user