c++: Fix error recovery when redeclaring enum in different module [PR99573]
commitbbb30f12a7e5ce008f59ec26c9e4cc65ee79fe56
authorNathaniel Shead <nathanieloshead@gmail.com>
Mon, 12 Feb 2024 01:40:15 +0000 (12 12:40 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Wed, 14 Feb 2024 11:06:16 +0000 (14 22:06 +1100)
tree3ae6734688b277e7743d1c3930d72329612d538b
parentd79aa77d9b2fe757b1bbda45defd4ac02b077a78
c++: Fix error recovery when redeclaring enum in different module [PR99573]

This ensures that with modules enabled, redeclaring an enum in the wrong
module or with the wrong underlying type no longer ICEs.

The patch also rearranges the order of the checks a little because I
think it's probably more important to note that you can't redeclare the
enum all before complaining about mismatched underlying types etc.

As a drive by this patch also adds some missing diagnostic groups, and
rewords the module redeclaration error message to more closely match the
wording used in other places this check is done.

PR c++/99573

gcc/cp/ChangeLog:

* decl.cc (start_enum): Reorder check for redeclaring in module.
Add missing auto_diagnostic_groups.

gcc/testsuite/ChangeLog:

* g++.dg/modules/enum-12.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
gcc/cp/decl.cc
gcc/testsuite/g++.dg/modules/enum-12.C [new file with mode: 0644]