From patchwork Tue May 13 00:19:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 348180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 9D5BA14007E for ; Tue, 13 May 2014 10:21:56 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=jcLYIw8m6g7vbsxba2Avit3854F26naB7OqpVV71Er4 jv3IRV+G1oNIzb6HJ56X50xNeQ70DaIJBmY7jX2pCX4kGwmII+uZTYZKOvgtj1wM cpPX3G6c3JBX19Ar+1AzPUniARJ5f2dvesvsQQEgmD2ecW8cO0rmfBmRJLBx13RM = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=gebv4lTGiWHmhINJZe5vKYzvVK0=; b=QjIkz/f1FcEG5Cqfg i0vJgS+FE/zQxsPixbajWRxd5qUaWwh150MrqFqBFIOobiitZ53DoXgtUy9HTMDz P8aTzdK6G6ilxMrvf3xhCp24FCBmjG5OrkT1JTs+rcTDp9Jx7VbY/pr3wYLnWK+3 qr1MJBeUdItmErOggz2kT35zKo= Received: (qmail 894 invoked by alias); 13 May 2014 00:21:49 -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 882 invoked by uid 89); 13 May 2014 00:21:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=none autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 13 May 2014 00:21:48 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4D0LjcK012203 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 13 May 2014 00:21:45 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s4D0LiVP014355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 May 2014 00:21:45 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4D0LicW002284; Tue, 13 May 2014 00:21:44 GMT Received: from [192.168.1.4] (/87.11.235.250) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 May 2014 17:21:44 -0700 Message-ID: <53716519.8010802@oracle.com> Date: Tue, 13 May 2014 02:19:37 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 60373 X-IsSubscribed: yes Hi, in this issue Marc noticed that the warning for ignored attribute visibility is truncated when the previous declaration belongs to a system header. Luckily the problem can be neatly fixed because it's just a consequence of not using warning_at + inform, as we should anyway. The other hunk in the patch tweaks the only other remaining warning_at pair I found in the file, should be a rather benign one, but better adjusting it too. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2014-05-13 Paolo Carlini PR c++/60373 * decl.c (duplicate_decls): Replace pair of warning_at with warning_at + inform. (maybe_commonize_var): Likewise. /testsuite 2014-05-13 Paolo Carlini PR c++/60373 * g++.dg/cpp0x/Wattributes1.C: New. * g++.dg/ext/visibility/redecl1.C: Adjust. * g++.dg/ext/visibility/visibility-7.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 210330) +++ cp/decl.c (working copy) @@ -2306,10 +2306,11 @@ duplicate_decls (tree newdecl, tree olddecl, bool && DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) { - warning_at (input_location, OPT_Wattributes, - "%q+D: visibility attribute ignored because it", newdecl); - warning_at (DECL_SOURCE_LOCATION (olddecl), OPT_Wattributes, - "conflicts with previous declaration here"); + if (warning_at (DECL_SOURCE_LOCATION (newdecl), OPT_Wattributes, + "%qD: visibility attribute ignored because it " + "conflicts with previous declaration", newdecl)) + inform (DECL_SOURCE_LOCATION (olddecl), + "previous declaration of %qD", olddecl); } /* Choose the declaration which specified visibility. */ if (DECL_VISIBILITY_SPECIFIED (olddecl)) @@ -5026,13 +5027,12 @@ maybe_commonize_var (tree decl) be merged. */ TREE_PUBLIC (decl) = 0; DECL_COMMON (decl) = 0; - warning_at (input_location, 0, - "sorry: semantics of inline function static " - "data %q+#D are wrong (you%'ll wind up " - "with multiple copies)", decl); - warning_at (DECL_SOURCE_LOCATION (decl), 0, - " you can work around this by removing " - "the initializer"); + if (warning_at (DECL_SOURCE_LOCATION (decl), 0, + "sorry: semantics of inline function static " + "data %q#D are wrong (you%'ll wind up " + "with multiple copies)", decl)) + inform (DECL_SOURCE_LOCATION (decl), + "you can work around this by removing the initializer"); } } } Index: testsuite/g++.dg/cpp0x/Wattributes1.C =================================================================== --- testsuite/g++.dg/cpp0x/Wattributes1.C (revision 0) +++ testsuite/g++.dg/cpp0x/Wattributes1.C (working copy) @@ -0,0 +1,8 @@ +// PR c++/60373 +// { dg-do compile { target c++11 } } +// { dg-require-visibility "" } + +#include +__attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" } + +// { dg-message "previous declaration" "" { target *-*-* } 128 } Index: testsuite/g++.dg/ext/visibility/redecl1.C =================================================================== --- testsuite/g++.dg/ext/visibility/redecl1.C (revision 210330) +++ testsuite/g++.dg/ext/visibility/redecl1.C (working copy) @@ -3,5 +3,5 @@ struct __attribute((visibility("hidden"))) B; struct __attribute((visibility("default"))) B; // { dg-error "visibility" } -__attribute ((visibility ("hidden"))) void f(); // { dg-warning "previous" } +__attribute ((visibility ("hidden"))) void f(); // { dg-message "previous" } __attribute ((visibility ("default"))) void f(); // { dg-warning "visibility" } Index: testsuite/g++.dg/ext/visibility/visibility-7.C =================================================================== --- testsuite/g++.dg/ext/visibility/visibility-7.C (revision 210330) +++ testsuite/g++.dg/ext/visibility/visibility-7.C (working copy) @@ -4,7 +4,7 @@ extern int __attribute__((visibility ("hidden"))) -xyzzy; /* { dg-warning "previous declaration here" "" } */ +xyzzy; /* { dg-message "previous declaration" "" } */ int __attribute__((visibility ("protected")))