From patchwork Mon Apr 15 08:04:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1923619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=U6VPEFkC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VJ08Q05hJz1yXv for ; Mon, 15 Apr 2024 18:05:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 314EF3858C60 for ; Mon, 15 Apr 2024 08:05:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 283E13858D34 for ; Mon, 15 Apr 2024 08:04:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 283E13858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 283E13858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713168280; cv=none; b=MUUBW5UDub3Bl0I4pA6Ynl9T49izIwp9KZDOPpFmvIBEq+V4f1qC9j8DLQNIyn2htOEjHtFMsmPVhH/lQWEybpA1LnPVtNiB8ZCgY7YRSd1OQrOnlrHP5qIGPo7XV2WeREvsris0ed/3aHzR8ZYjiXs5tLIc5i0xTREtIjN3jvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713168280; c=relaxed/simple; bh=Fq0klbldiSe+cAKFY4KCR3JL8mwR2w/3q8+z7UJZKmQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=k8Pt9qC2oV7tPZ6arwTRHsBlPHqElXYTPBuMxEJ+N/cQIogL3bbJXKhhXbjSF/1iAHLHMmRGymLtBDofix8IA2sa1wJhK6QZ4nQy0Tzl3pMoF4fijPcs2XSMBepZ2TyNnIWO73Ac0j2ejnPjkzFnYXaKe/21yEpWh+o/37/Qr64= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713168268; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=u9n9KbQeyMK0x6DPUHzYvFxxkW/kILzAOBqMtsWsAD0=; b=U6VPEFkCB1MLBTuDVa8QQxQXO1U/xWWpooJnxtwpoUjw35jeLqcIMr6/QYfIlvn0f7+KE8 CBsXGpqpMFK7m6WB1MGA+HyRt0h39y21gC/ObV+I+woJQ+HXCZpf/22YOPnX+MKzxh8xZa 2mSGsTj5HJglhtD6LWGGFNp6d1IzAT4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-BnQRArylN9ikfy9erpro8g-1; Mon, 15 Apr 2024 04:04:25 -0400 X-MC-Unique: BnQRArylN9ikfy9erpro8g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BDE580D678; Mon, 15 Apr 2024 08:04:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 212862166B34; Mon, 15 Apr 2024 08:04:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 43F84IfX051148 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 15 Apr 2024 10:04:18 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 43F84Io9051147; Mon, 15 Apr 2024 10:04:18 +0200 Date: Mon, 15 Apr 2024 10:04:17 +0200 From: Jakub Jelinek To: Richard Biener , "Joseph S. Myers" , Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] attribs: Don't crash on NULL TREE_TYPE in diag_attr_exclusions [PR114634] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! The enumerator still doesn't have TREE_TYPE set but diag_attr_exclusions assumes that all decls must have types. I think it is better in something as unimportant as diag_attr_exclusions to be more robust, if there is no type, it can just diagnose exclusions on the DECL_ATTRIBUTES, like for types it only diagnoses it on TYPE_ATTRIBUTES. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-04-15 Jakub Jelinek PR c++/114634 * attribs.cc (diag_attr_exclusions): Set attrs[1] to NULL_TREE for decls with NULL TREE_TYPE. * g++.dg/ext/attrib68.C: New test. Jakub --- gcc/attribs.cc.jj 2024-02-12 20:44:52.409074876 +0100 +++ gcc/attribs.cc 2024-04-12 18:29:52.000381917 +0200 @@ -468,7 +468,10 @@ diag_attr_exclusions (tree last_decl, tr if (DECL_P (node)) { attrs[0] = DECL_ATTRIBUTES (node); - attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node)); + if (TREE_TYPE (node)) + attrs[1] = TYPE_ATTRIBUTES (TREE_TYPE (node)); + else + attrs[1] = NULL_TREE; } else { --- gcc/testsuite/g++.dg/ext/attrib68.C.jj 2024-04-12 18:31:38.100968098 +0200 +++ gcc/testsuite/g++.dg/ext/attrib68.C 2024-04-12 18:30:57.011515625 +0200 @@ -0,0 +1,8 @@ +// PR c++/114634 +// { dg-do compile } + +template +struct A +{ + enum { e __attribute__ ((aligned (16))) }; // { dg-error "alignment may not be specified for 'e'" } +};