From patchwork Thu May 5 18:07:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1627102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=sHXMqR4W; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvMB94x81z9sBB for ; Fri, 6 May 2022 04:08:00 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BA393857431 for ; Thu, 5 May 2022 18:07:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BA393857431 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1651774078; bh=jQF2ClpYyP/RC02hgRzAB6b+ODVJmn31WOVdizkpZ48=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sHXMqR4WUEUXYY08JZkQZCqYTSoylkQAlusq6LiGid37eVxXE6xn6/8dolof3x5Br IwJosdr3rjs9DKLYvbTmFJtSverjlCMo2O7S4DOH/t2KGaTSgD1SsHAUJheh9iYsgX G1EEM3sFDKg9yUYNoZXZ+VgHE15WKURwV/l8DQms= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.129.74]) by sourceware.org (Postfix) with ESMTPS id 864B33858D3C for ; Thu, 5 May 2022 18:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 864B33858D3C Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-365-i0JXU8OFM3mcYypggr27wg-1; Thu, 05 May 2022 14:07:34 -0400 X-MC-Unique: i0JXU8OFM3mcYypggr27wg-1 Received: by mail-qt1-f198.google.com with SMTP id j18-20020ac806d2000000b002f354e9bc9eso3951175qth.10 for ; Thu, 05 May 2022 11:07:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=jQF2ClpYyP/RC02hgRzAB6b+ODVJmn31WOVdizkpZ48=; b=ToZXFVPnDJ2fK92a/RI6o53ZmnKigWXBTEA8rGO/m1GqSSVudFFeOocHA47qHdqhxj AEo+xxWIVNwX+mHFBsQqQXgXCRjQ6JleCV0Ksm6Hp405LI3Sf9SRHGb4HD5hKYf2iXhm bc+VjImhwlWwTbUaZFmrVAEBAfprcpPqeX6HwyGccRT/q+nqcM+gNGEawjFizYbBuCU4 ndVt71SzqDqAucI6hbc/xKKb+WzGyWCwz067vRbxRKg7Mmh6mbmYpV3aUhtd0BYRids3 HavoCjhjNJ+eXPKdMm2LL9uWYWEoOds0M6WKJJoUEA78xRci+fObrng61jioFof4U2Jx cDtQ== X-Gm-Message-State: AOAM531WdXwpg76nCun0ia+oMuH09HCWIbve/JP9sgorgSUEcfx8EI7C gINvAJVxR1vlAI4/wly5FQ/8elPq3fkZx5svUJyFPp5XND1huFP/HJ/E+Hw7jpHhhX4h9kEAqbs 2wLxo6cDPGHnDCJnxSuaJkIEtOtcTR0bk/ZaCxBpBE6xe7rK6c+iBbEcLBuKQs1Av7A== X-Received: by 2002:a05:622a:1210:b0:2f2:2620:8562 with SMTP id y16-20020a05622a121000b002f226208562mr25476512qtx.118.1651774053862; Thu, 05 May 2022 11:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUes29DdE7mpuWpXPkbgbeE9ETZ4PPbC6TY+BALWdJI+jZlG7JRLV8CTk7VHuG5oPMVXsAnA== X-Received: by 2002:a05:622a:1210:b0:2f2:2620:8562 with SMTP id y16-20020a05622a121000b002f226208562mr25476376qtx.118.1651774052053; Thu, 05 May 2022 11:07:32 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id f18-20020ac84992000000b002f3b82571b1sm1197881qtq.1.2022.05.05.11.07.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 11:07:30 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH RFA] attribs: fix typedefs in generic code [PR105492] Date: Thu, 5 May 2022 14:07:28 -0400 Message-Id: <20220505180728.2791914-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" In my patch for PR100545 I added an assert to check for broken typedefs in set_underlying_type, and it found one in this case: rs6000_handle_altivec_attribute had the same problem as handle_mode_attribute. So let's move the fixup into decl_attributes. Tested that this fixes the ICE on a cross compiler, regression tested x86_64-pc-linux-gnu, OK for trunk? PR c/105492 gcc/ChangeLog: * attribs.cc (decl_attributes): Fix broken typedefs here. gcc/c-family/ChangeLog: * c-attribs.cc (handle_mode_attribute): Don't fix broken typedefs here. --- gcc/attribs.cc | 15 +++++++++++++++ gcc/c-family/c-attribs.cc | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-) base-commit: 000f4480005035d0811e009a7cb25b42721f0a6e diff --git a/gcc/attribs.cc b/gcc/attribs.cc index b219f878042..0648391f0c6 100644 --- a/gcc/attribs.cc +++ b/gcc/attribs.cc @@ -872,6 +872,21 @@ decl_attributes (tree *node, tree attributes, int flags, tree ret = (spec->handler) (cur_and_last_decl, name, args, flags|cxx11_flag, &no_add_attrs); + /* Fix up typedefs clobbered by attribute handlers. */ + if (TREE_CODE (*node) == TYPE_DECL + && anode == &TREE_TYPE (*node) + && DECL_ORIGINAL_TYPE (*node) + && TYPE_NAME (*anode) == *node + && TYPE_NAME (cur_and_last_decl[0]) != *node) + { + tree t = cur_and_last_decl[0]; + DECL_ORIGINAL_TYPE (*node) = t; + tree tt = build_variant_type_copy (t); + cur_and_last_decl[0] = tt; + TREE_TYPE (*node) = tt; + TYPE_NAME (tt) = *node; + } + *anode = cur_and_last_decl[0]; if (ret == error_mark_node) { diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index b1953a45f9b..a280987c111 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -2204,16 +2204,6 @@ handle_mode_attribute (tree *node, tree name, tree args, TYPE_QUALS (type)); if (TYPE_USER_ALIGN (type)) *node = build_aligned_type (*node, TYPE_ALIGN (type)); - - tree decl = node[2]; - if (decl && TYPE_NAME (type) == decl) - { - /* Set up the typedef all over again. */ - DECL_ORIGINAL_TYPE (decl) = NULL_TREE; - TREE_TYPE (decl) = *node; - set_underlying_type (decl); - *node = TREE_TYPE (decl); - } } return NULL_TREE;