From patchwork Mon Jul 2 10:58:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 937809 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-480832-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T3wI3VX2"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="swyjJy8O"; 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 41K43w2G0Rz9s2R for ; Mon, 2 Jul 2018 20:58:19 +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:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=DUUgExobk0ZsMfOzoS42xqYQb3ownQ56m4FYe2x+YqdSxRqqvf d1q0HCU27h0sCDGKjx3giZX328X+jvIFoPHTx/6K8SjHH9e81u4sLD/+vDzuOSpl 9bKB4hKyC7a7aYxjW1KbBrIYpGK/IGkvGYcEhxZgos8DzCl0y3jv7XKuk= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=eFY7+v/MoxcjMA8T/UKhXqkqHz0=; b=T3wI3VX2OrNedPSriPCy gD1TR7SQebYICsRauyFAUAA+4w+Hnnx73C/UidN7Fk+Rl9VEhL3jgBO1/JPpsNUX 1rSEUY9WlIbQvSVY9bENDj0W2xyktEKBXmIxc/oQDSd/MPnmaBaQw9qtWsddhfA/ fECPnKxkFlb8DSuoTqnz31k= Received: (qmail 32405 invoked by alias); 2 Jul 2018 10:58:13 -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 32392 invoked by uid 89); 2 Jul 2018 10:58:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:Gateway, parserc, UD:parser.c, parser.c X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Jul 2018 10:58:11 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w62Arp0W040625; Mon, 2 Jul 2018 10:58:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2017-10-26; bh=z9JPy2j+UCj55634k+mfhTiRkJL47CEJXDE65UdCVGQ=; b=swyjJy8OBI0jZvQTv7RgRWDvSfHnHo3RLVmmIe9ECvhap6QxiUKHiqCZ8h1kOPCL2Env CipKq8WsiaPJCfEWsjdzQn2mGkQsWPnRkoUVpCqOooyct5Kr5iqb8NURZbnLYLAfMAyv rRi8XtFIylwoSS5doX6rxVXQyYiFYwG+0LqmiQM+8UpSnFibfliJlqAr5Ps8QxpHZxMg M3cQ/4OZTbbK7Q1f41YeiiclWp8YpoJT3XWkYdZDf/GwGlZCQKzAEbHdPouMUzhu/mIS Y8/vW1EUcupgFkU1rLxqRj4xhDqtL9n7n4qBWAgsf8jjSDUVZYzJ9N9RtTOsMEVPi4tr IQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2jx19sm0xc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 02 Jul 2018 10:58:08 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w62Aw8W5027708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 2 Jul 2018 10:58:08 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w62Aw7xm006492; Mon, 2 Jul 2018 10:58:07 GMT Received: from [192.168.1.4] (/87.17.229.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 02 Jul 2018 03:58:06 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , David Malcolm From: Paolo Carlini Subject: [C++ Patch] Adjust one more error message to use rich_location::add_range Message-ID: Date: Mon, 2 Jul 2018 12:58:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, I was double checking my pending patch and going through the errors we emit in decl.c and elsewhere about thread_local and __thread and noticed another place, in parser.c, where using rich_location::add_range seems natural. Note, we could in principle swap location and decl_specs->locations[ds_thread] in the error basing on the gnu bool and ensure that the caret always points to __thread. All in all, I don't think it's worth it... Thanks, Paolo. /////////////// /cp 2018-07-02 Paolo Carlini * parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range in error message about __thread and thread_local at the same time. /testsuite 2018-07-02 Paolo Carlini * g++.dg/diagnostic/thread-thread_local.C: New. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 262300) +++ cp/parser.c (working copy) @@ -28377,12 +28377,15 @@ set_and_check_decl_spec_loc (cp_decl_specifier_seq else if (ds == ds_thread) { bool gnu = token_is__thread (token); + gcc_rich_location richloc (location); if (gnu != decl_specs->gnu_thread_keyword_p) - error_at (location, - "both %<__thread%> and % specified"); + { + richloc.add_range (decl_specs->locations[ds_thread], false); + error_at (&richloc, + "both %<__thread%> and % specified"); + } else { - gcc_rich_location richloc (location); richloc.add_fixit_remove (); error_at (&richloc, "duplicate %qD", token->u.value); } Index: testsuite/g++.dg/diagnostic/thread-thread_local.C =================================================================== --- testsuite/g++.dg/diagnostic/thread-thread_local.C (nonexistent) +++ testsuite/g++.dg/diagnostic/thread-thread_local.C (working copy) @@ -0,0 +1,13 @@ +// { dg-options "-fdiagnostics-show-caret" } +// { dg-do compile { target c++11 } } + +thread_local __thread int a; // { dg-error "14:both .__thread. and .thread_local. specified" } +/* { dg-begin-multiline-output "" } + thread_local __thread int a; + ~~~~~~~~~~~~ ^~~~~~~~ + { dg-end-multiline-output "" } */ +__thread thread_local int b; // { dg-error "10:both .__thread. and .thread_local. specified" } +/* { dg-begin-multiline-output "" } + __thread thread_local int b; + ~~~~~~~~ ^~~~~~~~~~~~ + { dg-end-multiline-output "" } */