From patchwork Fri Jun 24 18:59:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1648141 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=ssGyhl4s; 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 4LV5yv2yd1z9ryY for ; Sat, 25 Jun 2022 04:59:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B86B1383F965 for ; Fri, 24 Jun 2022 18:59:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B86B1383F965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1656097188; bh=fVRtff0eCxH9/rxZjMGe2GXNqyq5pYj8E3d90H66hAA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ssGyhl4seZsEITNT2KCx3I5NGQqRH0rDqcCN1dMFy2McOEzcivYYJ/FXUJ6sq1TMC 8PK+Y4LoBh9+HHClQSGvH4BAYoPJTdpyrKAQCm0MomsOy9ezDzTnpZVGjwdPp0U+S+ 9WyS8F+7oySZAg6daYBnH/DSPCAHPXs5UOn+sYfs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id 0F7A6384D194 for ; Fri, 24 Jun 2022 18:59:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F7A6384D194 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4LV5yD0Yzwz9sT3; Fri, 24 Jun 2022 20:59:16 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Give consistent error message when attribute argument not a string constant Date: Fri, 24 Jun 2022 20:59:13 +0200 Message-Id: <20220624185913.3907944-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4LV5yD0Yzwz9sT3 X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch adjusts all the "not a string" errors in the D attribute handlers to use the same format string for consistency. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, and committed to mainline. Regards, Iain. --- gcc/d/ChangeLog: * d-attribs.cc (d_handle_section_attribute): Update error message. (d_handle_symver_attribute): Likewise. (d_handle_no_sanitize_attribute): Likewise. (d_handle_visibility_attribute): Likewise. gcc/testsuite/ChangeLog: * gdc.dg/attr_section1.d: Update dg-error. * gdc.dg/attr_visibility1.d: Likewise. --- gcc/d/d-attribs.cc | 11 ++++++----- gcc/testsuite/gdc.dg/attr_section1.d | 2 +- gcc/testsuite/gdc.dg/attr_visibility1.d | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc index 23bbe3946fb..b7b014f72be 100644 --- a/gcc/d/d-attribs.cc +++ b/gcc/d/d-attribs.cc @@ -1015,7 +1015,7 @@ d_handle_section_attribute (tree *node, tree name, tree args, int flags, if (TREE_CODE (TREE_VALUE (args)) != STRING_CST) { - error ("section attribute argument not a string constant"); + error ("%qE attribute argument not a string constant", name); *no_add_attrs = true; return NULL_TREE; } @@ -1065,7 +1065,8 @@ d_handle_section_attribute (tree *node, tree name, tree args, int flags, struct attribute_spec.handler. */ static tree -d_handle_symver_attribute (tree *node, tree, tree args, int, bool *no_add_attrs) +d_handle_symver_attribute (tree *node, tree name, tree args, int, + bool *no_add_attrs) { if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL) { @@ -1088,7 +1089,7 @@ d_handle_symver_attribute (tree *node, tree, tree args, int, bool *no_add_attrs) tree symver = TREE_VALUE (args); if (TREE_CODE (symver) != STRING_CST) { - error ("% attribute argument not a string constant"); + error ("%qE attribute argument not a string constant", name); *no_add_attrs = true; return NULL_TREE; } @@ -1391,7 +1392,7 @@ d_handle_no_sanitize_attribute (tree *node, tree name, tree args, int, tree id = TREE_VALUE (args); if (TREE_CODE (id) != STRING_CST) { - error ("%qE argument not a string", name); + error ("%qE attribute argument not a string constant", name); return NULL_TREE; } @@ -1525,7 +1526,7 @@ d_handle_visibility_attribute (tree *node, tree name, tree args, tree id = TREE_VALUE (args); if (TREE_CODE (id) != STRING_CST) { - error ("visibility argument not a string"); + error ("%qE attribute argument not a string constant", name); return NULL_TREE; } diff --git a/gcc/testsuite/gdc.dg/attr_section1.d b/gcc/testsuite/gdc.dg/attr_section1.d index c24634f7fd5..759b203dd44 100644 --- a/gcc/testsuite/gdc.dg/attr_section1.d +++ b/gcc/testsuite/gdc.dg/attr_section1.d @@ -7,7 +7,7 @@ import gcc.attributes; struct S {} // { dg-warning ".section. attribute does not apply to types" } @attribute("section", 123) -int f1(); // { dg-error "section attribute argument not a string constant" } +int f1(); // { dg-error ".section. attribute argument not a string constant" } int f2(@section("param") int a) // { dg-error "section attribute not allowed for .a." } { diff --git a/gcc/testsuite/gdc.dg/attr_visibility1.d b/gcc/testsuite/gdc.dg/attr_visibility1.d index a7ed4065605..932e6e6051f 100644 --- a/gcc/testsuite/gdc.dg/attr_visibility1.d +++ b/gcc/testsuite/gdc.dg/attr_visibility1.d @@ -13,7 +13,7 @@ void nested() } @attribute("visibility", 123) -int not_a_string(); // { dg-error "visibility argument not a string" } +int not_a_string(); // { dg-error ".visibility. attribute argument not a string constant" } @attribute("visibility", "invalid argument") int invalid_argument(); // { dg-error ".visibility. argument must be one of" }