public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96571] New: Bad "set but not used" warning with _Generic
@ 2020-08-11 16:33 jsm28 at gcc dot gnu.org
2020-08-12 9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2020-08-11 16:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
Bug ID: 96571
Summary: Bad "set but not used" warning with _Generic
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
Target Milestone: ---
Compile the following with -Wall:
enum E { V };
int
f (void)
{
enum E v;
return _Generic (v, enum E : 0);
}
This produces a warning:
t.c: In function 'f':
t.c:6:10: warning: variable 'v' set but not used [-Wunused-but-set-variable]
6 | enum E v;
| ^
It's arguable whether the variable is "used" when it's only referenced in the
controlling expression of _Generic (so never actually evaluated), but it's
certainly not set.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
@ 2020-08-12 9:12 ` jakub at gcc dot gnu.org
2020-08-13 16:40 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-12 9:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You should then mark_exp_read the _Generic controlling expression.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
2020-08-12 9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
@ 2020-08-13 16:40 ` jakub at gcc dot gnu.org
2020-08-18 5:52 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-08-13 16:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-08-13
Ever confirmed|0 |1
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49057
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49057&action=edit
gcc11-pr96571.patch
Untested fix.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
2020-08-12 9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
2020-08-13 16:40 ` jakub at gcc dot gnu.org
@ 2020-08-18 5:52 ` cvs-commit at gcc dot gnu.org
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-18 5:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
--- Comment #3 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:6d42cbe5ad7a7b46437f2576c9920e44dc14b386
commit r11-2732-g6d42cbe5ad7a7b46437f2576c9920e44dc14b386
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 18 07:51:58 2020 +0200
c: Fix -Wunused-but-set-* warning with _Generic [PR96571]
The following testcase shows various problems with -Wunused-but-set*
warnings and _Generic construct. I think it is best to treat the selector
and the ignored expressions as (potentially) read, because when they are
parsed, the vars in there are already marked as TREE_USED.
2020-08-18 Jakub Jelinek <jakub@redhat.com>
PR c/96571
* c-parser.c (c_parser_generic_selection): Change match_found from
bool
to int, holding index of the match. Call mark_exp_read on the
selector
expression and on expressions other than the selected one.
* gcc.dg/Wunused-var-4.c: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
` (2 preceding siblings ...)
2020-08-18 5:52 ` cvs-commit at gcc dot gnu.org
@ 2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:23 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:57 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:5c16de18f26df961e00a049f198aeb9dce8de225
commit r10-8668-g5c16de18f26df961e00a049f198aeb9dce8de225
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 18 07:51:58 2020 +0200
c: Fix -Wunused-but-set-* warning with _Generic [PR96571]
The following testcase shows various problems with -Wunused-but-set*
warnings and _Generic construct. I think it is best to treat the selector
and the ignored expressions as (potentially) read, because when they are
parsed, the vars in there are already marked as TREE_USED.
2020-08-18 Jakub Jelinek <jakub@redhat.com>
PR c/96571
* c-parser.c (c_parser_generic_selection): Change match_found from
bool
to int, holding index of the match. Call mark_exp_read on the
selector
expression and on expressions other than the selected one.
* gcc.dg/Wunused-var-4.c: New test.
(cherry picked from commit 6d42cbe5ad7a7b46437f2576c9920e44dc14b386)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
` (3 preceding siblings ...)
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
@ 2020-09-16 19:23 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:57 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 19:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:d2472e513c6490b6e2832b07d08731df26e6dc06
commit r9-8909-gd2472e513c6490b6e2832b07d08731df26e6dc06
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Aug 18 07:51:58 2020 +0200
c: Fix -Wunused-but-set-* warning with _Generic [PR96571]
The following testcase shows various problems with -Wunused-but-set*
warnings and _Generic construct. I think it is best to treat the selector
and the ignored expressions as (potentially) read, because when they are
parsed, the vars in there are already marked as TREE_USED.
2020-08-18 Jakub Jelinek <jakub@redhat.com>
PR c/96571
* c-parser.c (c_parser_generic_selection): Change match_found from
bool
to int, holding index of the match. Call mark_exp_read on the
selector
expression and on expressions other than the selected one.
* gcc.dg/Wunused-var-4.c: New test.
(cherry picked from commit 6d42cbe5ad7a7b46437f2576c9920e44dc14b386)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/96571] Bad "set but not used" warning with _Generic
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
` (4 preceding siblings ...)
2020-09-16 19:23 ` cvs-commit at gcc dot gnu.org
@ 2020-09-17 17:57 ` jakub at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-09-17 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96571
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For 8.5 fixed in r8-10512-g2346f2b89780790210816eeea12b817e61652b26 , for 9.4+
and 10.3+ and 11.1+ by the above commits.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-09-17 17:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 16:33 [Bug c/96571] New: Bad "set but not used" warning with _Generic jsm28 at gcc dot gnu.org
2020-08-12 9:12 ` [Bug c/96571] " jakub at gcc dot gnu.org
2020-08-13 16:40 ` jakub at gcc dot gnu.org
2020-08-18 5:52 ` cvs-commit at gcc dot gnu.org
2020-08-25 17:45 ` cvs-commit at gcc dot gnu.org
2020-09-16 19:23 ` cvs-commit at gcc dot gnu.org
2020-09-17 17:57 ` jakub 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).