c-decl: fix "inform" grouping and conditionalization
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 16 Jun 2022 21:36:38 +0000 (17:36 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 16 Jun 2022 21:36:38 +0000 (17:36 -0400)
commitd3e0da54c16e5383b9b969b7b40f7eadb35b0b8e
tree526c8a2985cb0b4992061eb522a97dc96075f8fd
parentf0da5f0a3161310f2180cccc42a26e0bd02030f0
c-decl: fix "inform" grouping and conditionalization

Whilst working on SARIF output I noticed some places where followup notes
weren't being properly associated with their errors/warnings in c-decl.cc.

Whilst fixing those I noticed some places where we "inform" after a
"warning" without checking that the warning was actually emitted.

Fixed the various issues seen in gcc/c/c-decl.cc thusly.

gcc/c/ChangeLog:
* c-decl.cc (implicitly_declare): Add auto_diagnostic_group to
group the warning with any note.
(warn_about_goto): Likewise to group error or warning with note.
Bail out if the warning wasn't emitted, to avoid emitting orphan
notes.
(lookup_label_for_goto): Add auto_diagnostic_group to
group the error with the note.
(check_earlier_gotos): Likewise.
(c_check_switch_jump_warnings): Likewise for any error/warning.
Conditionalize emission of the notes.
(diagnose_uninitialized_cst_member): Likewise for warning,
conditionalizing emission of the note.
(grokdeclarator): Add auto_diagnostic_group to group the "array
type has incomplete element type" error with any note.
(parser_xref_tag): Add auto_diagnostic_group to group warnings
with their notes.  Conditionalize emission of notes.
(start_struct): Add auto_diagnostic_group to group the
"redefinition of" errors with any note.
(start_enum): Likewise for "redeclaration of %<enum %E%>" error.
(check_for_loop_decls): Likewise for pre-C99 error.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/c/c-decl.cc