]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: Introduce -Wfree-labels
authorFlorian Weimer <fweimer@redhat.com>
Wed, 27 Nov 2024 08:32:31 +0000 (09:32 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 27 Nov 2024 08:32:31 +0000 (09:32 +0100)
commit631cd92b3b3d187860df004d212c4d7f6db517b7
tree28f97c75481b765c760081250d82204f5bacc92d
parent2fd9aef1db1a4260ee823bc3a3d4cfc22e95c543
c: Introduce -Wfree-labels

This is another recent GCC extension whose use is apparently
difficult to spot in code reviews.

The name of the option is due to Jonathan Wakely.  Part of it
could apply to C++ as well (for labels at the end of a compound
statement).

gcc/c-family/

* c-opts.cc (c_common_post_options): Initialize
warn_free_labels.
* c.opt (Wfree-labels): New option.
* c.opt.urls: Regenerate.

gcc/c/

* c-parser.cc (c_parser_compound_statement_nostart): Use
OPT_Wfree_labels for warning about labels on declarations.
(c_parser_compound_statement_nostart): Use OPT_Wfree_labels
for warning about labels at end of compound statements.

gcc/

* doc/invoke.texi: Document -Wfree-labels.

gcc/testsuite/

* gcc.dg/Wfree-labels-1.c: New test.
* gcc.dg/Wfree-labels-2.c: New test.
* gcc.dg/Wfree-labels-3.c: New test.
gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/c-family/c.opt.urls
gcc/c/c-parser.cc
gcc/doc/invoke.texi
gcc/testsuite/gcc.dg/Wfree-labels-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wfree-labels-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wfree-labels-3.c [new file with mode: 0644]