re PR c++/84940 (internal compiler error: in build_value_init_noctor, at cp/init...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 27 Sep 2018 08:33:41 +0000 (08:33 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 27 Sep 2018 08:33:41 +0000 (08:33 +0000)
/cp
2018-09-27  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/84940
* g++.dg/expr/unary4.C: New.

From-SVN: r264664

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/unary4.C [new file with mode: 0644]

index 672626c27d981f249e0301124fba6c00709d581c..a28b6150d8f5df53fa47dbc2708a23c3c163a133 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       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  <jakub@redhat.com>
 
        PR c++/87398
index bf3c63a09a1fbe98723d567174519ea53d9bd074..c7f53d1206e853acaa60d4fa1e78d02661956f94 100644 (file)
@@ -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);
index b7dd6734bca29c54af40244b816a27d1d8fe3455..4bca408202237f919e540acd0abe2e4ce54256fc 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84940
+       * g++.dg/expr/unary4.C: New.
+
 2018-09-26  Indu Bhagat  <indu.bhagat@oracle.com>
 
        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 (file)
index 0000000..2b58a8d
--- /dev/null
@@ -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" }
+}