From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 0221E3858C62 for ; Tue, 20 Sep 2022 21:06:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0221E3858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663707961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Epmcc3S/9BTVTtW0ArTAY23IY3drqI8n6GqEjdr3yoc=; b=eo971CplRYsEZ6YdDyPwpMIAjf7YzDgMRVCVAIo9L3y/GTTKY3H1uJk1lwgw02cc/b7eF4 EmRm+z4jyyZfOnR4eEXmVKtY0rcGDFrac1bwt6RVi/Z92veWDsVQA2r9jJtIb4wzTDKl9v veXPQz7F1KBVEz2thuUZtRmp6YueoTQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-252-W0S2EtGEN0i7UuXrgYfjHA-1; Tue, 20 Sep 2022 17:06:00 -0400 X-MC-Unique: W0S2EtGEN0i7UuXrgYfjHA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 098C085A5B6 for ; Tue, 20 Sep 2022 21:06:00 +0000 (UTC) Received: from pdp-11.lan (unknown [10.22.9.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC2631759F; Tue, 20 Sep 2022 21:05:59 +0000 (UTC) From: Marek Polacek To: Jason Merrill , GCC Patches Subject: [PATCH] c++: ICE-on-invalid with designated initializer [PR106983] Date: Tue, 20 Sep 2022 17:05:52 -0400 Message-Id: <20220920210552.835987-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? 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. --- gcc/cp/typeck2.cc | 2 +- gcc/testsuite/g++.dg/other/error36.C | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/other/error36.C 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}; +} base-commit: be60aa5b608b5f09fadfeff852a46589ac311a42 -- 2.37.3