[Bug c/88660] [8/9/10 Regression] Invalid report of "set but used variable" with -O

2020-01-30 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88660

--- Comment #3 from CVS Commits  ---
The master branch has been updated by Jeff Law :

https://gcc.gnu.org/g:f9eb0973edb2b4eed4cdbba7105b8af7afe5b547

commit r10-6360-gf9eb0973edb2b4eed4cdbba7105b8af7afe5b547
Author: Jeff Law 
Date:   Thu Jan 30 14:09:41 2020 -0700

Mark switch expression as used to avoid bogus warning

PR c/88660
* c-parser.c (c_parser_switch_statement): Make sure to request
marking the switch expr as used.

PR c/88660
* gcc.dg/pr88660.c: New test.

[Bug c/88660] [8/9/10 Regression] Invalid report of "set but used variable" with -O

2020-01-28 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88660

Jeffrey A. Law  changed:

   What|Removed |Added

 CC||law at redhat dot com
   Assignee|unassigned at gcc dot gnu.org  |law at redhat dot com

--- Comment #2 from Jeffrey A. Law  ---
I think we've just got the wrong value for the last argument to the
convert_lvalue_to_ravlue call within c_parser_switch_statement.  That argument
controls whether or not we mark the expression with DECL_READ_P.

[Bug c/88660] [8/9/10 Regression] Invalid report of "set but used variable" with -O

2020-01-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88660

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c/88660] [8/9/10 Regression] Invalid report of "set but used variable" with -O

2019-10-22 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88660

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |8.4

[Bug c/88660] [8/9/10 Regression] Invalid report of "set but used variable" with -O

2019-09-29 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88660

Martin Sebor  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-09-29
 CC||msebor at gcc dot gnu.org
  Known to work||7.3.0
 Blocks||89180
Summary|Invalid report of "set but  |[8/9/10 Regression] Invalid
   |used variable" with -O  |report of "set but used
   ||variable" with -O
 Ever confirmed|0   |1
  Known to fail||10.0, 8.3.0, 9.2.0

--- Comment #1 from Martin Sebor  ---
Confirmed.  Bisection points to r254930 as the revision that caused the
regression:

r254930 | jakub | 2017-11-19 12:17:01 -0500 (Sun, 19 Nov 2017) | 28 lines

PR c/66618
PR c/69960
c-family/
* c-common.h (c_fully_fold): Add LVAL argument defaulted to false.
c/
* c-parser.c (c_parser_omp_atomic): Pass true as LVAL to c_fully_fold
where needed.
* c-typeck.c (build_unary_op, build_modify_expr, build_asm_expr,
handle_omp_array_sections): Likewise.
(digest_init): Don't call decl_constant_value_for_optimization.
* c-tree.h (decl_constant_value_for_optimization): Removed.
* c-fold.c (c_fold_array_ref): New function.
(c_fully_fold_internal): Add LVAL argument, propagate it through
recursive calls.  For VAR_P call decl_constant_value and
unshare if not LVAL and either optimizing or IN_INIT.  Remove
decl_constant_value_for_optimization calls.  If IN_INIT and not LVAL,
fold ARRAY_REF with STRING_CST and INTEGER_CST operands.
(c_fully_fold): Add LVAL argument, pass it through to
c_fully_fold_internal.
(decl_constant_value_for_optimization): Removed.
cp/
* cp-gimplify.c (c_fully_fold): Add LVAL argument, call
cp_fold_maybe_rvalue instead of cp_fold_rvalue and pass it !LVAL.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89180
[Bug 89180] [meta-bug] bogus/missing -Wunused warnings