From d69aeeeed06b0fe5567f04343cf7a8a7aa3e26f5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 12 Feb 2018 23:25:41 +0100 Subject: [PATCH] re PR c++/84341 (ICE with #pragma omp atomic) 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: r257607 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 14 ++++++++------ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/gomp/pr84341.c | 10 ++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr84341.c diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f12a35a1b5..c2b19d8eb59 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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-12 Nathan Sidwell PR c++/84263 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e1e8741d21d..9a05e4fc812 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -9330,12 +9330,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 a3843839604..40261753993 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-12 Jakub Jelinek + + PR c++/84341 + * c-c++-common/gomp/pr84341.c: New test. + 2018-02-12 Thomas Koenig PR fortran/68746 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 00000000000..557f1ba21bd --- /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" } */ +} -- 2.30.2