From: Jakub Jelinek Date: Mon, 19 Feb 2018 19:16:26 +0000 (+0100) Subject: re PR c++/84448 (ICE with broken condition in parallel for loop) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4382537df8cc3d0d8622af606e4ce580d1bb4c80;p=gcc.git re PR c++/84448 (ICE with broken condition in parallel for loop) PR c++/84448 * parser.c (cp_parser_binary_expression): For no_toplevel_fold_p, if either operand is error_mark_node, set current.lhs to that instead of creating a binary op with error_mark_node operands. * g++.dg/gomp/pr84448.C: New test. From-SVN: r257821 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 58fc0935903..870dde6388d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2018-02-19 Jakub Jelinek + PR c++/84448 + * parser.c (cp_parser_binary_expression): For no_toplevel_fold_p, if + either operand is error_mark_node, set current.lhs to that instead of + creating a binary op with error_mark_node operands. + PR c++/84430 * constexpr.c (potential_constant_expression_1): Handle OMP_SIMD. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 81c6f0128e6..d8d788052ab 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9331,12 +9331,18 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, && lookahead_prec <= current.prec && sp == stack) { - current.lhs - = build_min (current.tree_type, - TREE_CODE_CLASS (current.tree_type) == tcc_comparison - ? boolean_type_node : TREE_TYPE (current.lhs), - current.lhs.get_value (), rhs.get_value ()); - SET_EXPR_LOCATION (current.lhs, combined_loc); + if (current.lhs == error_mark_node || rhs == error_mark_node) + current.lhs = error_mark_node; + else + { + current.lhs + = build_min (current.tree_type, + TREE_CODE_CLASS (current.tree_type) + == tcc_comparison + ? boolean_type_node : TREE_TYPE (current.lhs), + current.lhs.get_value (), rhs.get_value ()); + SET_EXPR_LOCATION (current.lhs, combined_loc); + } } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fcb1d33b8da..b4df63d9963 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-02-19 Jakub Jelinek + PR c++/84448 + * g++.dg/gomp/pr84448.C: New test. + PR c++/84430 * g++.dg/gomp/pr84430.C: New test. diff --git a/gcc/testsuite/g++.dg/gomp/pr84448.C b/gcc/testsuite/g++.dg/gomp/pr84448.C new file mode 100644 index 00000000000..3fad4741d38 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr84448.C @@ -0,0 +1,17 @@ +// PR c++/84448 +// { dg-do compile } + +struct A +{ + operator int () const; + A& operator += (int); + A& operator ++ (); +}; + +void +foo (A a, A b) +{ + #pragma omp for + for (A i = a; i <=; ++i) // { dg-error "expected primary-expression before" } + ; // { dg-error "invalid controlling predicate" "" { target *-*-* } .-1 } +}