diff mbox series

[C++] PR 84940 ("[7/8/9 Regression] internal compiler error: in build_value_init_noctor, at cp/init.c:465")

Message ID 6ec42ea8-90b9-7953-bf03-1b1501baa40a@oracle.com
State New
Headers show
Series [C++] PR 84940 ("[7/8/9 Regression] internal compiler error: in build_value_init_noctor, at cp/init.c:465") | expand

Commit Message

Paolo Carlini Sept. 25, 2018, 4:45 p.m. UTC
Hi,

in this error-recovery regression we ICE after a sensible diagnostic 
emitted by cp_build_unary_op, called by finish_unary_op_expr via 
build_x_unary_op. In principle we could dig deeper, but I don't think it 
makes sense for finish_unary_op_expr to go on having seen the 
error_mark_node returned by build_x_unary_op given that the purpose of 
its second half is only issuing warnings.

Tested x86_64-linux.

Thanks, Paolo.

//////////////////////
/cp
2018-09-25  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-25  Paolo Carlini  <paolo.carlini@oracle.com>

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

Comments

Jason Merrill Sept. 26, 2018, 3:10 p.m. UTC | #1
OK.

On Tue, Sep 25, 2018 at 12:45 PM, Paolo Carlini
<paolo.carlini@oracle.com> wrote:
> Hi,
>
> in this error-recovery regression we ICE after a sensible diagnostic emitted
> by cp_build_unary_op, called by finish_unary_op_expr via build_x_unary_op.
> In principle we could dig deeper, but I don't think it makes sense for
> finish_unary_op_expr to go on having seen the error_mark_node returned by
> build_x_unary_op given that the purpose of its second half is only issuing
> warnings.
>
> Tested x86_64-linux.
>
> Thanks, Paolo.
>
> //////////////////////
>
>
diff mbox series

Patch

Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 264578)
+++ cp/semantics.c	(working copy)
@@ -2727,13 +2727,14 @@  finish_unary_op_expr (location_t op_loc, enum tree
   /* 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: testsuite/g++.dg/expr/unary4.C
===================================================================
--- testsuite/g++.dg/expr/unary4.C	(nonexistent)
+++ testsuite/g++.dg/expr/unary4.C	(working copy)
@@ -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" }
+}