From: Jakub Jelinek Date: Mon, 25 Jun 2018 17:21:04 +0000 (+0200) Subject: backport: re PR c++/84341 (ICE with #pragma omp atomic) X-Git-Tag: releases/gcc-6.5.0~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67475dbe5bf53be75b150d85a2e9d7001fe51c2b;p=thirdparty%2Fgcc.git backport: re PR c++/84341 (ICE with #pragma omp atomic) Backported from mainline 2018-02-12 Jakub Jelinek PR c++/84341 * parser.c (cp_parser_binary_expression): Use build_min instead of build2_loc to build the no_toplevel_fold_p toplevel binary expression. * c-c++-common/gomp/pr84341.c: New test. From-SVN: r262062 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9eb96f774db0..a48560fa5d3f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,12 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-02-12 Jakub Jelinek + + PR c++/84341 + * parser.c (cp_parser_binary_expression): Use build_min instead of + build2_loc to build the no_toplevel_fold_p toplevel binary expression. + 2018-02-10 Jakub Jelinek PR sanitizer/83987 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 4157c53b668a..b3a4ce4fe467 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8920,12 +8920,14 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p, if (no_toplevel_fold_p && lookahead_prec <= current.prec && sp == stack) - current.lhs = build2_loc (combined_loc, - current.tree_type, - TREE_CODE_CLASS (current.tree_type) - == tcc_comparison - ? boolean_type_node : TREE_TYPE (current.lhs), - current.lhs, rhs); + { + 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 { current.lhs = build_x_binary_op (combined_loc, current.tree_type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8530d2010f88..4e92dc30240d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-25 Jakub Jelinek Backported from mainline + 2018-02-12 Jakub Jelinek + + PR c++/84341 + * c-c++-common/gomp/pr84341.c: New test. + 2018-02-10 Jakub Jelinek PR sanitizer/83987 diff --git a/gcc/testsuite/c-c++-common/gomp/pr84341.c b/gcc/testsuite/c-c++-common/gomp/pr84341.c new file mode 100644 index 000000000000..557f1ba21bd9 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr84341.c @@ -0,0 +1,10 @@ +/* PR c++/84341 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +void +foo (int i) +{ + #pragma omp atomic + i = &i + 1; /* { dg-error "invalid form of" } */ +}