The following patch aims to removing the attribute only tf_waring flag is on.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d1c846ecf44..8ff46498fd6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7410,7 +7410,10 @@ canonicalize_type_argument (tree arg, tsubst_flags_t complain) if (!arg || arg == error_mark_node || arg == TYPE_CANONICAL (arg)) return arg; bool removed_attributes = false; - tree canon = strip_typedefs (arg, &removed_attributes); + bool *premove_attributes = NULL; + if (complain & tf_warning) + premove_attributes = &removed_attributes; + tree canon = strip_typedefs (arg, premove_attributes); if (removed_attributes && (complain & tf_warning)) warning (OPT_Wignored_attributes,