Hi,

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...

Tested x86_64-linux.

Thanks, Paolo.

//////////////////////

/cp
2018-10-16  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84705
        * call.c (perform_direct_initialization_if_possible): Early return
        error_mark_node if build_special_member_call returns it.

/testsuite
2018-10-16  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84705
        * g++.dg/cpp0x/pr84705.C: New.
Index: cp/call.c
===================================================================
--- cp/call.c   (revision 265200)
+++ cp/call.c   (working copy)
@@ -10995,6 +10995,8 @@ perform_direct_initialization_if_possible (tree ty
       expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
                                        &args, type, LOOKUP_NORMAL, complain);
       release_tree_vector (args);
+      if (expr == error_mark_node)
+       return error_mark_node;
       return build_cplus_new (type, expr, complain);
     }
 
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;
+  })));
+};

Reply via email to