]> gcc.gnu.org Git - gcc.git/commit
c: Fix -Wunused-but-set-* warning with _Generic [PR96571]
authorJakub Jelinek <jakub@redhat.com>
Tue, 18 Aug 2020 05:51:58 +0000 (07:51 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 25 Aug 2020 14:57:48 +0000 (16:57 +0200)
commit5c16de18f26df961e00a049f198aeb9dce8de225
tree5c2f024b03bbf61de6fc6989407a488b2dd0b0b5
parent7151b3d700efcd0994bc1a6cfc36f5abc53c7f5a
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)
gcc/c/c-parser.c
gcc/testsuite/gcc.dg/Wunused-var-4.c [new file with mode: 0644]
This page took 0.065743 seconds and 6 git commands to generate.