===================================================================
@@ -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");
}
}
}
===================================================================
@@ -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 }
===================================================================
@@ -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" }
===================================================================
@@ -4,7 +4,7 @@
extern int
__attribute__((visibility ("hidden")))
-xyzzy; /* { dg-warning "previous declaration here" "" } */
+xyzzy; /* { dg-message "previous declaration" "" } */
int
__attribute__((visibility ("protected")))