https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95288
Bug ID: 95288 Summary: Poor error message with function-scope enum definition Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nathan at gcc dot gnu.org Target Milestone: --- Created attachment 48587 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48587&action=edit testcase A malformed enum definition in function-scope gives a very poor diagnostic. In this example I typoed a '.' (DOT) for a ',' (COMMA). the compiler complains at the 'enum' token, not at the dot. Contrast the error for X and (namespace-scope) Y. Class-scope enums behave like namespace-scope ones. (1)bester:139>g++ -c f.cc f.cc: In function ‘void f()’: f.cc:4:3: error: expected primary-expression before ‘enum’ 4 | enum X | ^~~~ f.cc: At global scope: f.cc:13:4: error: expected ‘}’ before ‘.’ token 13 | c. // DOT | ^ f.cc:12:1: note: to match this ‘{’ 12 | { | ^ f.cc:13:4: error: expected unqualified-id before ‘.’ token 13 | c. // DOT | ^ f.cc:15:1: error: expected declaration before ‘}’ token 15 | };