This PR is a request to add a way how to suppress the warning about ignored attributes. We concluded that -Wattributes isn't the right warning for this case, so I went ahead with Richi's suggestion to add -Wignored-attributes.
Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-03-23 Marek Polacek <pola...@redhat.com> PR c++/69884 * c.opt (Wignored-attributes): New option. * pt.c (canonicalize_type_argument): Use OPT_Wignored_attributes. * doc/invoke.texi: Document -Wignored-attributes. * g++.dg/warn/Wignored-attributes-1.C: New test. * g++.dg/warn/Wignored-attributes-2.C: New test. diff --git gcc/c-family/c.opt gcc/c-family/c.opt index 7c5f6c7..4f86876 100644 --- gcc/c-family/c.opt +++ gcc/c-family/c.opt @@ -482,6 +482,10 @@ Wignored-qualifiers C C++ Var(warn_ignored_qualifiers) Warning EnabledBy(Wextra) Warn whenever type qualifiers are ignored. +Wignored-attributes +C C++ Var(warn_ignored_attributes) Init(1) Warning +Warn whenever attributes are ignored. + Wincompatible-pointer-types C ObjC Var(warn_incompatible_pointer_types) Init(1) Warning Warn when there is a conversion between pointers that have incompatible types. diff --git gcc/cp/pt.c gcc/cp/pt.c index 45cd1ea..6837438 100644 --- gcc/cp/pt.c +++ gcc/cp/pt.c @@ -6950,7 +6950,8 @@ canonicalize_type_argument (tree arg, tsubst_flags_t complain) tree canon = strip_typedefs (arg, &removed_attributes); if (removed_attributes && (complain & tf_warning)) - warning (0, "ignoring attributes on template argument %qT", arg); + warning (OPT_Wignored_attributes, + "ignoring attributes on template argument %qT", arg); return canon; } diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi index 99ac11b..9e54bb7 100644 --- gcc/doc/invoke.texi +++ gcc/doc/invoke.texi @@ -267,7 +267,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol -Wformat-security -Wformat-signedness -Wformat-y2k -Wframe-address @gol -Wframe-larger-than=@var{len} -Wno-free-nonheap-object -Wjump-misses-init @gol --Wignored-qualifiers -Wincompatible-pointer-types @gol +-Wignored-qualifiers -Wignored-attributes -Wincompatible-pointer-types @gol -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol -Winit-self -Winline -Wno-int-conversion @gol -Wno-int-to-pointer-cast -Winvalid-memory-model -Wno-invalid-offsetof @gol @@ -3886,6 +3886,14 @@ even without this option. This warning is also enabled by @option{-Wextra}. +@item -Wignored-attributes @r{(C and C++ only)} +@opindex Wignored-attributes +@opindex Wno-ignored-attributes +Warn when an attribute is ignored. This is different from the +@option{-Wattributes} option in that it warns whenever the compiler decides +to drop an attribute, not that the attribute is either unknown, used in a +wrong place, etc. This warning is enabled by default. + @item -Wmain @opindex Wmain @opindex Wno-main diff --git gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C index e69de29..46ccc4a 100644 --- gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C +++ gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C @@ -0,0 +1,6 @@ +// PR c++/69884 +// { dg-do compile } + +typedef float __m128 __attribute__((__vector_size__(16), __may_alias__)); +template <typename> struct A; +template <> struct A<__m128>; // { dg-warning "ignoring attributes on template argument" } diff --git gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C index e69de29..6431607 100644 --- gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C +++ gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C @@ -0,0 +1,7 @@ +// PR c++/69884 +// { dg-do compile } +// { dg-options "-Wno-ignored-attributes" } + +typedef float __m128 __attribute__((__vector_size__(16), __may_alias__)); +template <typename> struct A; +template <> struct A<__m128>; Marek