On Mon, Aug 14, 2017 at 10:25:22AM +0200, Tom de Vries wrote: > 2017-08-14 Tom de Vries <t...@codesourcery.com> > > PR c/81844
Please use PR c/81875 instead, now that you've filed it. > * c-parser.c (c_parser_omp_for_loop): Fix condition folding. Fold only operands of cond, not cond itself. ? > * testsuite/libgomp.c/pr81805.c: New test. Wouldn't it be worth to test it also for C++? I know we don't have libgomp.c-c++-common (maybe we should add that), so the current way would be add libgomp.c++/pr81805.C that #includes the other test source (if you tweak it for C++, it would need #ifdef __cplusplus "C" #endif for abort). > --- a/gcc/c/c-parser.c > +++ b/gcc/c/c-parser.c > @@ -15027,7 +15027,24 @@ c_parser_omp_for_loop (location_t loc, c_parser > *parser, enum tree_code code, > > cond = cond_expr.value; > cond = c_objc_common_truthvalue_conversion (cond_loc, cond); > - cond = c_fully_fold (cond, false, NULL); > + switch (TREE_CODE (cond)) Just do if (COMPARISON_CLASS_P (cond)) instead of the switch? > + { > + case GT_EXPR: > + case GE_EXPR: > + case LT_EXPR: > + case LE_EXPR: > + case NE_EXPR: > + { > + tree op0 = TREE_OPERAND (cond, 0), op1 = TREE_OPERAND (cond, 1); > + op0 = c_fully_fold (op0, false, NULL); > + op1 = c_fully_fold (op1, false, NULL); > + TREE_OPERAND (cond, 0) = op0; > + TREE_OPERAND (cond, 1) = op1; > + } > + break; > + default: > + break; > + } > switch (cond_expr.original_code) > { > case GT_EXPR: Ok with those changes and sorry for the review delay. Jakub