]> git.ipfire.org Git - people/ms/gcc.git/commit
c, c++, cgraphunit: Prevent duplicated -Wunused-value warnings [PR108079]
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Mar 2023 09:10:24 +0000 (10:10 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sun, 19 Mar 2023 05:28:56 +0000 (06:28 +0100)
commite4984838f6af868399ef9d885377199c38907ee1
tree39f6b382374760e9e1c51ed294280fa2f3c02370
parent93aafc14410388875313719a76b92812911a861a
c, c++, cgraphunit: Prevent duplicated -Wunused-value warnings [PR108079]

On the following testcase, we warn with -Wunused-value twice, once
in the FEs and later on cgraphunit again with slightly different
wording.

The following patch fixes that by registering a warning suppression in the
FEs when we warn and not warning in cgraphunit anymore if that happened.

2023-03-10  Jakub Jelinek  <jakub@redhat.com>

PR c/108079
gcc/
* cgraphunit.cc (check_global_declaration): Don't warn for unused
variables which have OPT_Wunused_variable warning suppressed.
gcc/c/
* c-decl.cc (pop_scope): Suppress OPT_Wunused_variable warning
after diagnosing it.
gcc/cp/
* decl.cc (poplevel): Suppress OPT_Wunused_variable warning
after diagnosing it.
gcc/testsuite/
* c-c++-common/Wunused-var-18.c: New test.

(cherry picked from commit 2c63cc7268fd5615997989f153e9405d0f5aaa50)
gcc/c/c-decl.cc
gcc/cgraphunit.cc
gcc/cp/decl.cc
gcc/testsuite/c-c++-common/Wunused-var-18.c [new file with mode: 0644]