Index: gcc/c-family/c-common.c |
=================================================================== |
--- gcc/c-family/c-common.c (revision 190493) |
+++ gcc/c-family/c-common.c (working copy) |
@@ -8502,9 +8502,22 @@ handle_target_attribute (tree *node, tree name, tr |
warning (OPT_Wattributes, "%qE attribute ignored", name); |
*no_add_attrs = true; |
} |
- else if (! targetm.target_option.valid_attribute_p (*node, name, args, |
- flags)) |
- *no_add_attrs = true; |
+ else |
+ { |
+ /* When a target attribute is invalid, it may also be because the |
+ target for the compilation unit and the attribute match. For |
+ instance, target attribute "xxx" is invalid when -mxxx is used. |
+ When used with multiversioning, removing the attribute will lead |
+ to duplicate definitions if a default version is provided. |
+ So, generate a warning here and remove the attribute. */ |
+ if (!targetm.target_option.valid_attribute_p (*node, name, args, flags)) |
+ { |
+ warning (OPT_Wattributes, |
+ "Invalid target attribute in function %qE, ignored.", |
+ *node); |
+ *no_add_attrs = true; |
+ } |
+ } |
return NULL_TREE; |
} |