public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable
@ 2022-12-13 4:50 stephenheumann at gmail dot com
2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: stephenheumann at gmail dot com @ 2022-12-13 4:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Bug ID: 108079
Summary: -Wunused-variable gives misleading duplicate warning
for unused static local variable
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: stephenheumann at gmail dot com
Target Milestone: ---
For this program:
int main(void) {
static int x;
}
gcc -Wunused-variable reports:
<source>: In function 'main':
<source>:2:20: warning: unused variable 'x' [-Wunused-variable]
2 | static int x;
| ^
<source>: At top level:
<source>:2:20: warning: 'x' defined but not used [-Wunused-variable]
These two warnings are about the same thing, except the second one is
incorrectly labeled "At top level." There should just be one warning, without
"At top level."
C++ does the same thing, except it says "At global scope" instead of "At top
level."
This seems to be a regression that occurred in GCC 6: 5.4 just gives one
warning, but 6.1 also gives the extra one with "At top level."
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12/13 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
@ 2022-12-13 12:16 ` rguenth at gcc dot gnu.org
2022-12-21 14:14 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-13 12:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|-Wunused-variable gives |[10/11/12/13 Regression]
|misleading duplicate |-Wunused-variable gives
|warning for unused static |misleading duplicate
|local variable |warning for unused static
| |local variable
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2022-12-13
Known to work| |5.5.0
Target Milestone|--- |10.5
Priority|P3 |P2
Known to fail| |6.1.0
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12/13 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
@ 2022-12-21 14:14 ` jakub at gcc dot gnu.org
2022-12-21 14:40 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-21 14:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems to have started with r6-1401-gd7438551ff5ffa0afeca2aa3efd13035b26bee34
One of the warnings is diagnosed by the FE (from pop_scope/poplevel),
the other by cgraphunit (check_global_declaration).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12/13 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-12-21 14:14 ` jakub at gcc dot gnu.org
@ 2022-12-21 14:40 ` jakub at gcc dot gnu.org
2023-03-10 9:15 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-21 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54143
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54143&action=edit
gcc13-pr108079.patch
Untested fix.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12/13 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
` (2 preceding siblings ...)
2022-12-21 14:40 ` jakub at gcc dot gnu.org
@ 2023-03-10 9:15 ` cvs-commit at gcc dot gnu.org
2023-03-10 9:19 ` [Bug c/108079] [10/11/12 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-10 9:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:2c63cc7268fd5615997989f153e9405d0f5aaa50
commit r13-6575-g2c63cc7268fd5615997989f153e9405d0f5aaa50
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Mar 10 10:10:24 2023 +0100
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
` (3 preceding siblings ...)
2023-03-10 9:15 ` cvs-commit at gcc dot gnu.org
@ 2023-03-10 9:19 ` jakub at gcc dot gnu.org
2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-10 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12/13 Regression] |[10/11/12 Regression]
|-Wunused-variable gives |-Wunused-variable gives
|misleading duplicate |misleading duplicate
|warning for unused static |warning for unused static
|local variable |local variable
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11/12 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
` (4 preceding siblings ...)
2023-03-10 9:19 ` [Bug c/108079] [10/11/12 " jakub at gcc dot gnu.org
@ 2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:30 ` [Bug c/108079] [10/11 " jakub at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c/108079] [11 " rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-19 5:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:e4984838f6af868399ef9d885377199c38907ee1
commit r12-9287-ge4984838f6af868399ef9d885377199c38907ee1
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Mar 10 10:10:24 2023 +0100
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)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [10/11 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
` (5 preceding siblings ...)
2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org
@ 2023-03-20 10:30 ` jakub at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c/108079] [11 " rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-20 10:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12 Regression] |[10/11 Regression]
|-Wunused-variable gives |-Wunused-variable gives
|misleading duplicate |misleading duplicate
|warning for unused static |warning for unused static
|local variable |local variable
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 12.3 too.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/108079] [11 Regression] -Wunused-variable gives misleading duplicate warning for unused static local variable
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
` (6 preceding siblings ...)
2023-03-20 10:30 ` [Bug c/108079] [10/11 " jakub at gcc dot gnu.org
@ 2023-07-07 10:44 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108079
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-07-07 10:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 4:50 [Bug c/108079] New: -Wunused-variable gives misleading duplicate warning for unused static local variable stephenheumann at gmail dot com
2022-12-13 12:16 ` [Bug c/108079] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2022-12-21 14:14 ` jakub at gcc dot gnu.org
2022-12-21 14:40 ` jakub at gcc dot gnu.org
2023-03-10 9:15 ` cvs-commit at gcc dot gnu.org
2023-03-10 9:19 ` [Bug c/108079] [10/11/12 " jakub at gcc dot gnu.org
2023-03-19 5:30 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:30 ` [Bug c/108079] [10/11 " jakub at gcc dot gnu.org
2023-07-07 10:44 ` [Bug c/108079] [11 " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).