diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a100ff1d200..1b102c5e5d8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Marek Polacek + + PR c++/69884 + * doc/invoke.texi: Document -Wignored-attributes. + 2016-03-23 Bin Cheng PR tree-optimization/69042 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9944759d90c..c1188d7e5c0 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Marek Polacek + + PR c++/69884 + * c.opt (Wignored-attributes): New option. + 2016-03-22 David Malcolm PR c/69993 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 7c5f6c7b5cc..4f86876c533 100644 --- a/gcc/c-family/c.opt +++ b/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 a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6557f909635..d36168957ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2016-03-23 Marek Polacek + + PR c++/69884 + * pt.c (canonicalize_type_argument): Use OPT_Wignored_attributes. + 2016-03-22 Ilya Enkovich * call.c (build_conditional_expr_1): Always use original diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 45cd1eaaf4f..68374389f3b 100644 --- a/gcc/cp/pt.c +++ b/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 a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 99ac11b7714..9e54bb75737 100644 --- a/gcc/doc/invoke.texi +++ b/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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7ce1d289e82..93b731266ab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-03-23 Marek Polacek + + PR c++/69884 + * g++.dg/warn/Wignored-attributes-1.C: New test. + * g++.dg/warn/Wignored-attributes-2.C: New test. + 2016-03-23 Tom de Vries * c-c++-common/goacc/kernels-default.c (foo): Add missing diff --git a/gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C b/gcc/testsuite/g++.dg/warn/Wignored-attributes-1.C new file mode 100644 index 00000000000..46ccc4a12f9 --- /dev/null +++ b/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 struct A; +template <> struct A<__m128>; // { dg-warning "ignoring attributes on template argument" } diff --git a/gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C b/gcc/testsuite/g++.dg/warn/Wignored-attributes-2.C new file mode 100644 index 00000000000..6431607aaec --- /dev/null +++ b/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 struct A; +template <> struct A<__m128>;