Hi,
On 16/10/18 22:49, Jason Merrill wrote:
On Tue, Oct 16, 2018 at 2:39 PM Paolo Carlini <paolo.carl...@oracle.com> wrote:
the main issue is already fixed in trunk - we don't ICE anymore - but I
noticed that for ill-formed code like:
int i = static_cast<struct d>(i);
we emit a duplicate diagnostic about the incomplete type d, easy to
avoid by returning error_mark_node from
perform_direct_initialization_if_possible when build_special_member_call
returns it. I think this latter tweak qualifies as obvious, per a
comment made by Jason a while ago...
Yes, but in this case it might be better to handle it in
build_cplus_new, to also cover other uses of that function.
Ok... Then, I'm finishing testing the below. Thanks!
Paolo.
////////////////
Index: cp/tree.c
===================================================================
--- cp/tree.c (revision 265200)
+++ cp/tree.c (working copy)
@@ -646,6 +646,9 @@ build_cplus_new (tree type, tree init, tsubst_flag
tree rval = build_aggr_init_expr (type, init);
tree slot;
+ if (init == error_mark_node)
+ return error_mark_node;
+
if (!complete_type_or_maybe_complain (type, init, complain))
return error_mark_node;
Index: testsuite/g++.dg/cpp0x/pr84705.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr84705.C (nonexistent)
+++ testsuite/g++.dg/cpp0x/pr84705.C (working copy)
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int a[]{a}; // { dg-error "invalid conversion" }
+
+template<int>
+struct b {
+ __attribute__((c([] {
+ struct {
+ int a = static_cast<struct d>(a); // { dg-error "invalid use of
incomplete type" }
+ } e;
+ })));
+};