From patchwork Thu Jun 25 15:38:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1317009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=urg6SXvF; dkim-atps=neutral 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 (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49t41g6l8vz9sRW for ; Fri, 26 Jun 2020 01:39:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D690388A819; Thu, 25 Jun 2020 15:39:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D690388A819 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593099541; bh=Lw0Yu0gBPdPk/kktFE1ekoiyaHMnjgU1oj5LJLbiCJ8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=urg6SXvF9nQ08PoUWPu+wAksG2MoNIpyQdj3MZYIMvn8DSyjRRvppb62JxNQb3TrE NJ0skQit8qQ4xDfDKv4SF2R8Ci937Yc0eplho38CrZzu7IGq9/5kxrtgGHIM7n4olu 9aRL5QxR3P4mK54QPE0KgxSIr/psufziNCEz3kdQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id 55B39388A806 for ; Thu, 25 Jun 2020 15:38:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 55B39388A806 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 49t41Z2ZlLzKmg5; Thu, 25 Jun 2020 17:38:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id 8UnOMZqp060S; Thu, 25 Jun 2020 17:38:54 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Fix ICE in uda_attribute_p when looking up unknown attribute Date: Thu, 25 Jun 2020 17:38:20 +0200 Message-Id: <20200625153828.2304469-3-ibuclaw@gdcproject.org> In-Reply-To: <20200625153828.2304469-1-ibuclaw@gdcproject.org> References: <20200625153828.2304469-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: 3 X-Rspamd-Score: 0.49 / 15.00 / 15.00 X-Rspamd-Queue-Id: 1A05D175C X-Rspamd-UID: e87689 X-Spam-Status: No, score=-16.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch fixes an ICE in uda_attribute_p when looking up an unknown attribute. The target attribute table is not guaranteed to be set by all backends. Bootstrapped and regression tested on x86_64-linux-gnu, and committed to mainline. Regards Iain. --- gcc/d/ChangeLog: PR d/95173 * d-attribs.cc (uda_attribute_p): Don't search target attribute table if NULL. gcc/testsuite/ChangeLog: PR d/95173 * gdc.dg/pr95173.d: New test. --- gcc/d/d-attribs.cc | 9 ++++++--- gcc/testsuite/gdc.dg/pr95173.d | 10 ++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gdc.dg/pr95173.d diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc index 964f59f96f4..f4086c0f0ee 100644 --- a/gcc/d/d-attribs.cc +++ b/gcc/d/d-attribs.cc @@ -216,10 +216,13 @@ uda_attribute_p (const char *name) return true; } - for (const attribute_spec *p = targetm.attribute_table; p->name; p++) + if (targetm.attribute_table) { - if (get_identifier (p->name) == ident) - return true; + for (const attribute_spec *p = targetm.attribute_table; p->name; p++) + { + if (get_identifier (p->name) == ident) + return true; + } } return false; diff --git a/gcc/testsuite/gdc.dg/pr95173.d b/gcc/testsuite/gdc.dg/pr95173.d new file mode 100644 index 00000000000..2a4b2ed8232 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr95173.d @@ -0,0 +1,10 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95173 +// { dg-do compile } +// { dg-options "-Wattributes" } + +import gcc.attribute; + +@attribute("foo") // { dg-warning "unknown attribute .foo." } +void f95173() +{ +}