]> git.ipfire.org Git - thirdparty/gcc.git/commit
c: avoid false positive for useless casts and generic [PR125261]
authorMartin Uecker <uecker@tugraz.at>
Tue, 12 May 2026 05:11:38 +0000 (07:11 +0200)
committerMartin Uecker <uecker@gcc.gnu.org>
Wed, 13 May 2026 04:57:26 +0000 (06:57 +0200)
commitdee30fc0e980ee26a804a74da74decc0cea10b8f
tree8f21f0499a2b48e1884c1c9a0a16e902eecac558
parent9d5c276dfb5f5812e0fa7b46e84beaca36295c6d
c: avoid false positive for useless casts and generic [PR125261]

To reduce the number of false positives, we guard -Wuseless-cast by
c_inhibit_evaluation_warnings and also increment it for a generic
association if we have seen a prior match for a (non-default)
association.  This covers the common case where the default association
comes last.  If there is another association selected after we have
seen a default, we still have false positives.

PR c/125261

gcc/c/ChangeLog:
* c-parser.cc (c_parser_generic_selection): Modify logic for
c_inhibit_evaluation_warnings.
* c-typeck.cc (build_c_cast): Use c_inhibit_evaluation_warnings.

gcc/testsuite/ChangeLog:
* gcc.dg/pr125261.c: New test.
gcc/c/c-parser.cc
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/pr125261.c [new file with mode: 0644]