From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1734) id 8E0403858D38; Fri, 23 Sep 2022 00:24:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E0403858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663892667; bh=vinLyYgD4OpBjsrreZHVy3ftYiVBGAeKZgK7rrGmh5U=; h=From:To:Subject:Date:From; b=fLIRcve6/tKHAByARxNS3pV/uzwh1cU7XWqFEnQ21XkUZfnrOqp0IGKiuvorhVxbn FbdQeMSBwKDGe0YEdl5auRPTyFFB9B8PBcTph/KWuFPSqTiUvq84DdzIgDc6jb5YPK WcGvpOZDgpyUTNcPW1ONzRWxajEF96ybahwR/35A= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marek Polacek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2803] c++: ICE-on-invalid with designated initializer [PR106983] X-Act-Checkin: gcc X-Git-Author: Marek Polacek X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 279c671509d6b2fbaa8dff360c4f8d85f84a20c6 X-Git-Newrev: 8b449dcd84334068c769a2f427812dadb95e61de Message-Id: <20220923002427.8E0403858D38@sourceware.org> Date: Fri, 23 Sep 2022 00:24:27 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8b449dcd84334068c769a2f427812dadb95e61de commit r13-2803-g8b449dcd84334068c769a2f427812dadb95e61de Author: Marek Polacek Date: Tue Sep 20 14:54:57 2022 -0400 c++: ICE-on-invalid with designated initializer [PR106983] 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. Diff: --- gcc/cp/typeck2.cc | 2 +- gcc/testsuite/g++.dg/other/error36.C | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc index 688e9c15326..75fd0e2a9bf 100644 --- a/gcc/cp/typeck2.cc +++ b/gcc/cp/typeck2.cc @@ -597,7 +597,7 @@ split_nonconstant_init_1 (tree dest, tree init, bool last, 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); diff --git a/gcc/testsuite/g++.dg/other/error36.C b/gcc/testsuite/g++.dg/other/error36.C new file mode 100644 index 00000000000..556287816fd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error36.C @@ -0,0 +1,13 @@ +// 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}; +}