c++: Fix invalid -Wduplicated-cond warning [PR94265]
This fixes a false-positive warning from -Wduplicate-cond in the presence of an if-statement with a non-empty init-statement. Precisely determining whether a non-empty init-statement has side effects seems tricky and error-prone, so this patch takes the route of unconditionally invalidating the condition chain when it encounters such an if-statement. gcc/cp/ChangeLog: PR c++/94265 * parser.c (cp_parser_selection_statement) <case RID_IF>: Invalidate the current condition chain when the if-statement has a non-empty init-statement. gcc/testsuite/ChangeLog: PR c++/94265 * g++.dg/warn/Wduplicated-cond1.C: New test.
Showing
Please
register
or
sign in
to comment