https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114691
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:91146346f57cc54dfeb2669347edd0eb3d13af7f commit r14-9944-g91146346f57cc54dfeb2669347edd0eb3d13af7f Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Apr 12 20:53:10 2024 +0200 c++: Fix bogus warnings about ignored annotations [PR114691] The middle-end warns about the ANNOTATE_EXPR added for while/for loops if they declare a var inside of the loop condition. This is because the assumption is that ANNOTATE_EXPR argument is used immediately in a COND_EXPR (later GIMPLE_COND), but simplify_loop_decl_cond wraps the ANNOTATE_EXPR inside of a TRUTH_NOT_EXPR, so it no longer holds. The following patch fixes that by adding the TRUTH_NOT_EXPR inside of the ANNOTATE_EXPR argument if any. 2024-04-12 Jakub Jelinek <ja...@redhat.com> PR c++/114691 * semantics.cc (simplify_loop_decl_cond): Use cp_build_unary_op with TRUTH_NOT_EXPR on ANNOTATE_EXPR argument (if any) rather than ANNOTATE_EXPR itself. * g++.dg/ext/pr114691.C: New test.