We ICE in the code added in r12-7117: type_build_dtor_call gets
the error_mark_node because the type of 'prev' wasn't declared.
PR c++/106983
gcc/cp/ChangeLog:
* typeck2.cc (split_nonconstant_init_1): Check TYPE_P.
gcc/testsuite/ChangeLog:
* g++.dg/other/error36.C: New test.
if (prev == field_index)
break;
tree ptype = TREE_TYPE (prev);
- if (type_build_dtor_call (ptype))
+ if (TYPE_P (ptype) && type_build_dtor_call (ptype))
{
tree pcref = build3 (COMPONENT_REF, ptype, dest, prev,
NULL_TREE);
--- /dev/null
+// PR c++/106983
+// { dg-do compile { target c++20 } }
+
+typedef unsigned long long A;
+typedef union
+{
+ struct B s; // { dg-error "incomplete" }
+ A a;
+} U;
+void f (A x, unsigned int b)
+{
+ const U y = {.a = x};
+}