From patchwork Mon Jan 7 17:08:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1021457 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-493554-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="exkhckhp"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="xkKmyprw"; 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 43YML951Q3z9sCX for ; Tue, 8 Jan 2019 04:08:48 +1100 (AEDT) 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=WJy9d7NqEu0TFLBnuM9pg2bkyotPLNnd4eEZBh11lmKKRcsA9a p+kEFXya7FocqK7Drygrq+xNJW6fLGZ0J3Kmua3zmx+inbcySVWhDJxc/eGZaZRU xfvo00WmtsjmrnmRnLz43qCFi78uJiU80SIpmxcNn7NRddPHoMwEfhkJQ= 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=suPVbHFotSsXh6rGvqyNcJk2bmc=; b=exkhckhpPn6S0a8DE32K Cj9pOV57pZkIx3Iqod5QycKObgqH5dbE3lYjXip3pW5Fq+L5oIj9g2g0UEs3/g6e O3NajJddLCwNh6GoyH7p7Zg6aKKVfcVbqHVqEsRgOIPQShIzdXekTpaeDf2OFmqf 53WhbzatzW4nkysm4Q5zUTo= Received: (qmail 26494 invoked by alias); 7 Jan 2019 17:08:41 -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 26471 invoked by uid 89); 7 Jan 2019 17:08:40 -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=ok, H*r:Gateway, H*r:8.14.4 X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Jan 2019 17:08:38 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07H3ZeI008869; Mon, 7 Jan 2019 17:08:36 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-2018-07-02; bh=cks+OJ2sFNxg2AkAZgb08x5fqeg50QOoe84ASEAoAo8=; b=xkKmyprw0nbsoPNmARxGrejyK9obix2b7PMKftHDn2Dy5UWYz0eFIP4MjrCMcifdXivc nLEw17vHMgB0wRXFRK82KnkI2HqdVYYQQg6GtK3dEka/jWJybkXsl9gaZ11d8LEpryPu I2tWWxmzdVg9KH5toW592JRFCLep44Lzt41Ay47VdG/MR88PCnoF+vAgeE+LxClfLCSH ecPUIUhBF88XjJX2qhvCKNLSt9xiVWLq06MoN8JdBrx4nGAg8L0DpkZarPv9HjFZS5Vb OC8sQdBcgBi0UW6uc+1POdo7Zx9o1XNqBKZ+EPIB+pIsCCEhxGne+dbo3oOxs5kwwe8V rA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2ptj3dq6m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 17:08:36 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x07H8Upp023372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 17:08:30 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x07H8Urp007484; Mon, 7 Jan 2019 17:08:30 GMT Received: from [192.168.1.4] (/80.181.224.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 09:08:30 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] Fix four more locations Message-ID: Date: Mon, 7 Jan 2019 18:08:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, should be straightforward material. Tested x86_64-linux, as usual. Thanks, Paolo. ///////////////////// /cp 2019-01-07 Paolo Carlini * decl.c (start_decl): Improve two error_at locations. (expand_static_init): Likewise. /testsuite 2019-01-07 Paolo Carlini * g++.dg/diagnostic/constexpr1.C: New. * g++.dg/diagnostic/thread1.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 267651) +++ cp/decl.c (working copy) @@ -5235,10 +5236,12 @@ start_decl (const cp_declarator *declarator, { bool ok = false; if (CP_DECL_THREAD_LOCAL_P (decl)) - error ("%qD declared % in % function", - decl); + error_at (DECL_SOURCE_LOCATION (decl), + "%qD declared % in % function", + decl); else if (TREE_STATIC (decl)) - error ("%qD declared % in % function", decl); + error_at (DECL_SOURCE_LOCATION (decl), + "%qD declared % in % function", decl); else ok = true; if (!ok) @@ -8253,18 +8256,18 @@ expand_static_init (tree decl, tree init) if (CP_DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl) && !DECL_FUNCTION_SCOPE_P (decl)) { + location_t dloc = DECL_SOURCE_LOCATION (decl); if (init) - error ("non-local variable %qD declared %<__thread%> " - "needs dynamic initialization", decl); + error_at (dloc, "non-local variable %qD declared %<__thread%> " + "needs dynamic initialization", decl); else - error ("non-local variable %qD declared %<__thread%> " - "has a non-trivial destructor", decl); + error_at (dloc, "non-local variable %qD declared %<__thread%> " + "has a non-trivial destructor", decl); static bool informed; if (!informed) { - inform (DECL_SOURCE_LOCATION (decl), - "C++11 % allows dynamic initialization " - "and destruction"); + inform (dloc, "C++11 % allows dynamic " + "initialization and destruction"); informed = true; } return; Index: testsuite/g++.dg/diagnostic/constexpr1.C =================================================================== --- testsuite/g++.dg/diagnostic/constexpr1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/constexpr1.C (working copy) @@ -0,0 +1,5 @@ +// { dg-do compile { target c++11 } } + +constexpr void foo() { thread_local int i __attribute__((unused)) {}; } // { dg-error "41:.i. declared .thread_local." } + +constexpr void bar() { static int i __attribute__((unused)) {}; } // { dg-error "35:.i. declared .static." } Index: testsuite/g++.dg/diagnostic/thread1.C =================================================================== --- testsuite/g++.dg/diagnostic/thread1.C (nonexistent) +++ testsuite/g++.dg/diagnostic/thread1.C (working copy) @@ -0,0 +1,13 @@ +// { dg-do compile { target c++11 } } + +int foo(); + +__thread int i __attribute__((unused)) = foo(); // { dg-error "14:non-local variable .i. declared .__thread. needs" } + +struct S +{ + constexpr S() {} + ~S(); +}; + +__thread S s __attribute__((unused)); // { dg-error "12:non-local variable .s. declared .__thread. has" }