From 0798984a5a59e9162596db04cbf9eacc8541da7f Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 27 Sep 2018 08:33:41 +0000 Subject: [PATCH] re PR c++/84940 (internal compiler error: in build_value_init_noctor, at cp/init.c:465) /cp 2018-09-27 Paolo Carlini PR c++/84940 * semantics.c (finish_unary_op_expr): Check return value of build_x_unary_op for error_mark_node. /testsuite 2018-09-27 Paolo Carlini PR c++/84940 * g++.dg/expr/unary4.C: New. From-SVN: r264664 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/expr/unary4.C | 8 ++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/expr/unary4.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 672626c27d9..a28b6150d8f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-09-27 Paolo Carlini + + PR c++/84940 + * semantics.c (finish_unary_op_expr): Check return value of + build_x_unary_op for error_mark_node. + 2018-09-25 Jakub Jelinek PR c++/87398 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bf3c63a09a1..c7f53d1206e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2727,13 +2727,14 @@ finish_unary_op_expr (location_t op_loc, enum tree_code code, cp_expr expr, /* TODO: build_x_unary_op doesn't always honor the location. */ result.set_location (combined_loc); - tree result_ovl, expr_ovl; + if (result == error_mark_node) + return result; if (!(complain & tf_warning)) return result; - result_ovl = result; - expr_ovl = expr; + tree result_ovl = result; + tree expr_ovl = expr; if (!processing_template_decl) expr_ovl = cp_fully_fold (expr_ovl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b7dd6734bca..4bca4082022 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-09-27 Paolo Carlini + + PR c++/84940 + * g++.dg/expr/unary4.C: New. + 2018-09-26 Indu Bhagat PR gcov-profile/86957 diff --git a/gcc/testsuite/g++.dg/expr/unary4.C b/gcc/testsuite/g++.dg/expr/unary4.C new file mode 100644 index 00000000000..2b58a8dc2cb --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/unary4.C @@ -0,0 +1,8 @@ +// PR c++/84940 +// { dg-additional-options -Wno-vla } + +void +foo (int x) +{ + struct {} a[1][x](-a[0]); // { dg-error "wrong type argument to unary minus" } +} -- 2.30.2