From patchwork Wed Aug 9 10:45:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 799647 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-460089-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PbRkEzuz"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xS7Gl2XXJz9s75 for ; Wed, 9 Aug 2017 20:46:05 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=ydgZQkxIHHwkl2hdP v8QDMNOgvjRPTV1enJlC2CaGrKTeYEAfNLBN+7zhq/V4/DezXi5JPKiL8XXMOaC4 UFh23sXqvVh12fF+ajghkcy9DLfrm9WmnW8RSvMgYETt5pnkrMDK6Vo22omz9JSd huLPI5l6mn0oG9eyM4LOW59EN8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=R+1OUBImCXJKif923oJ/abE 5z/g=; b=PbRkEzuzeXRHcE+yGLnboGC913jmthG9N1TGD3+DXiCk1hQ0ADEJiAh fBXeGmrOuVBznM5sgkvc5jfi3ohEmmD384JkKdwuvRZWV4yqjze19hFI1mmqISk3 W7alOt9KG22WJ5kovMJhhSK9HzSsmUSkY7DfPvpWXdqlQq6x8wpg= Received: (qmail 76732 invoked by alias); 9 Aug 2017 10:45:53 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 74995 invoked by uid 89); 9 Aug 2017 10:45:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 09 Aug 2017 10:45:44 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 43729AB22; Wed, 9 Aug 2017 10:45:39 +0000 (UTC) Subject: Re: [PATCH][v2] Fix target attribute handling (PR c++/81355). To: Martin Sebor , Jeff Law , gcc-patches@gcc.gnu.org, Jason Merrill References: <23407770-6fdc-614c-22b9-8782c4d0d01d@redhat.com> <12b87224-9920-0376-3fa7-8e5fb434a6b0@gmail.com> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <8464ad76-cf88-efdf-2dc5-402ea6946f7a@suse.cz> Date: Wed, 9 Aug 2017 12:45:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes On 08/08/2017 08:03 PM, Martin Sebor wrote: > On 08/07/2017 10:59 PM, Martin Liška wrote: >> On 08/02/2017 09:56 PM, Martin Sebor wrote: >>> On 08/02/2017 01:04 PM, Jeff Law wrote: >>>> On 07/28/2017 05:13 AM, Martin Liška wrote: >>>>> Hello. >>>>> >>>>> Following patch skips empty strings in 'target' attribute. >>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. >>>>> >>>>> Ready to be installed? >>>>> Martin >>>>> >>>>> gcc/ChangeLog: >>>>> >>>>> 2017-07-13 Martin Liska >>>>> >>>>> PR c++/81355 >>>>> * attribs.c (sorted_attr_string): Skip empty strings. >>>>> >>>>> gcc/testsuite/ChangeLog: >>>>> >>>>> 2017-07-13 Martin Liska >>>>> >>>>> PR c++/81355 >>>>> * g++.dg/other/pr81355.C: New test. >>>> OK. THough one could legitimately ask if this ought to be a parsing error. >>> >>> I would suggest to at least issue a warning. It seems that >>> the empty string must almost certainly be a bug here, say due >>> to unintended macro expansion. >>> >>> Otherwise, if it should remain silently (and intentionally) >>> accepted, I recommend to document it. As it is, the manual >>> says that the "string" argument is equivalent to compiling >>> with -mstring which for "" would be rejected by the driver. >>> >>> Martin >> >> Thanks you both for feedback. I decided to come up with an error message for that. >> >> Feedback appreciated. > > My only comment is on the text of the error message. I think > the %' directive is supposed to be used instead of a bare > apostrophe. But rather than using the somewhat informal "can't" > I would suggest to follow other similar diagnostics that might > print something like: > > empty string in attribute % > > (analogous to "empty precision in %s format" or "empty scalar > initializer" etc. in gcc.pot) > > or > > attribute % argument may not be empty > > (similar to "output filename may not be empty"). > > Martin Hi. Thank you both for review, both notes resolved in v3. Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. Ready to be installed? Martin From 227a41219ebb9a10bda80767f5b5f3e460a3e9b9 Mon Sep 17 00:00:00 2001 From: marxin Date: Wed, 12 Jul 2017 15:51:45 +0200 Subject: [PATCH] Fix target attribute handling (PR c++/81355). gcc/ChangeLog: 2017-07-13 Martin Liska PR c++/81355 * c-attribs.c (handle_target_attribute): Report warning for an empty string argument of target attribute. gcc/testsuite/ChangeLog: 2017-07-13 Martin Liska PR c++/81355 * g++.dg/other/pr81355.C: New test. --- gcc/c-family/c-attribs.c | 13 +++++++++++++ gcc/testsuite/g++.dg/other/pr81355.C | 14 ++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/other/pr81355.C diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 626ffa1cde7..b4252229beb 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -3116,6 +3116,19 @@ handle_target_attribute (tree *node, tree name, tree args, int flags, flags)) *no_add_attrs = true; + /* Check that there's no empty string in values of the attribute. */ + for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t)) + { + tree value = TREE_VALUE (t); + if (TREE_CODE (value) == STRING_CST + && TREE_STRING_LENGTH (value) == 1 + && TREE_STRING_POINTER (value)[0] == '\0') + { + warning (OPT_Wattributes, "empty string in attribute %"); + *no_add_attrs = true; + } + } + return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/other/pr81355.C b/gcc/testsuite/g++.dg/other/pr81355.C new file mode 100644 index 00000000000..89d1b419581 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr81355.C @@ -0,0 +1,14 @@ +/* { dg-do compile { target x86_64-*-* } } */ + +__attribute__((target("default"))) +int foo() {return 1;} + +__attribute__((target("arch=core2", ""))) +int foo2() {return 2;} /* { dg-warning "empty string in attribute .target." } */ + +__attribute__((target("sse4.2", "", ""))) +int foo3() {return 2;} /* { dg-warning "empty string in attribute .target." } */ + +int main() { + return foo() + foo2() + foo3(); +} -- 2.13.3