public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 60373
@ 2014-05-13  0:21 Paolo Carlini
  2014-05-20 13:27 ` [Ping] " Paolo Carlini
  2014-05-20 14:08 ` Jason Merrill
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Carlini @ 2014-05-13  0:21 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 505 bytes --]

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.

//////////////////////

[-- Attachment #2: CL_60373 --]
[-- Type: text/plain, Size: 403 bytes --]

/cp
2014-05-13  Paolo Carlini  <paolo.carlini@oracle.com>

	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  <paolo.carlini@oracle.com>

	PR c++/60373
	* g++.dg/cpp0x/Wattributes1.C: New.
	* g++.dg/ext/visibility/redecl1.C: Adjust.
	* g++.dg/ext/visibility/visibility-7.C: Likewise.

[-- Attachment #3: patch_60373 --]
[-- Type: text/plain, Size: 3374 bytes --]

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 <new>
+__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")))

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Ping] [C++ Patch] PR 60373
  2014-05-13  0:21 [C++ Patch] PR 60373 Paolo Carlini
@ 2014-05-20 13:27 ` Paolo Carlini
  2014-05-20 14:08 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2014-05-20 13:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

Hi,

On 05/13/2014 02:19 AM, Paolo Carlini wrote:
> 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.
Ping rather early because this one should be rather straightforward...

Thanks!
Paolo.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [C++ Patch] PR 60373
  2014-05-13  0:21 [C++ Patch] PR 60373 Paolo Carlini
  2014-05-20 13:27 ` [Ping] " Paolo Carlini
@ 2014-05-20 14:08 ` Jason Merrill
  1 sibling, 0 replies; 3+ messages in thread
From: Jason Merrill @ 2014-05-20 14:08 UTC (permalink / raw)
  To: Paolo Carlini, gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-20 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-13  0:21 [C++ Patch] PR 60373 Paolo Carlini
2014-05-20 13:27 ` [Ping] " Paolo Carlini
2014-05-20 14:08 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).