diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index abaa4a3ca531..02c7c1bf5a41 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -799,7 +799,11 @@ simplify_loop_decl_cond (tree *cond_p, tree body) *cond_p = boolean_true_node; if_stmt = begin_if_stmt (); - cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, false, tf_warning_or_error); + cond_p = &cond; + while (TREE_CODE (*cond_p) == ANNOTATE_EXPR) + cond_p = &TREE_OPERAND (*cond_p, 0); + *cond_p = cp_build_unary_op (TRUTH_NOT_EXPR, *cond_p, false, + tf_warning_or_error); finish_if_stmt_cond (cond, if_stmt); finish_break_stmt (); finish_then_clause (if_stmt); diff --git a/gcc/testsuite/g++.dg/ext/pr114691.C b/gcc/testsuite/g++.dg/ext/pr114691.C new file mode 100644 index 000000000000..f11731f2d5d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr114691.C @@ -0,0 +1,22 @@ +// PR c++/114691 +// { dg-do compile } +// { dg-options "-O2 -Wall" } + +void qux (int); +int foo (int); + +void +bar (int x) +{ + #pragma GCC novector + while (int y = foo (x)) // { dg-bogus "ignoring loop annotation" } + qux (y); +} + +void +baz (int x) +{ + #pragma GCC novector + for (; int y = foo (x); ) // { dg-bogus "ignoring loop annotation" } + qux (y); +}