{
tree arg;
int str_len_sum = 0;
- int argnum = 1;
+ int argnum = 0;
for (arg = arglist; arg; arg = TREE_CHAIN (arg))
{
- unsigned int i;
const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
- int len = strlen (str);
-
+ size_t len = strlen (str);
str_len_sum += len + 1;
- if (arg != arglist)
+ for (const char *p = strchr (str, ','); p; p = strchr (p + 1, ','))
argnum++;
- for (i = 0; i < strlen (str); i++)
- if (str[i] == ',')
- argnum++;
+ argnum++;
}
- if (argnum == 1)
+ if (argnum <= 1)
return -1;
return str_len_sum;
}
for (arg = arglist; arg; arg = TREE_CHAIN (arg))
{
const char *str = TREE_STRING_POINTER (TREE_VALUE (arg));
-
size_t len = strlen (str);
+ for (const char *p = strchr (str, ','); p; p = strchr (p + 1, ','))
+ argnum++;
memcpy (attr_str + str_len_sum, str, len);
attr_str[str_len_sum + len] = TREE_CHAIN (arg) ? ',' : '\0';
str_len_sum += len + 1;
{
int i = 0;
bool has_default = false;
- char *attr = strtok (attr_str, ",");
- while (attr != NULL)
+ for (char *attr = strtok (attr_str, ",");
+ attr != NULL; attr = strtok (NULL, ","))
{
if (strcmp (attr, "default") == 0)
{
has_default = true;
- attr = strtok (NULL, ",");
continue;
}
- attrs[i] = attr;
- attr = strtok (NULL, ",");
- i++;
+ attrs[i++] = attr;
}
if (!has_default)
return -1;
create the appropriate clone for each valid target attribute. */
static bool
-expand_target_clones (struct cgraph_node *node, bool defenition)
+expand_target_clones (struct cgraph_node *node, bool definition)
{
int i;
/* Parsing target attributes separated by comma. */
{
error_at (DECL_SOURCE_LOCATION (node->decl),
"default target was not set");
+ XDELETEVEC (attrs);
+ XDELETEVEC (attr_str);
return false;
}
create_new_asm_name (attr, suffix);
/* Create new target clone. */
- cgraph_node *new_node = create_target_clone (node, defenition, suffix);
+ cgraph_node *new_node = create_target_clone (node, definition, suffix);
XDELETEVEC (suffix);
/* Set new attribute for the clone. */
tree attributes = make_attribute ("target", attr,
DECL_ATTRIBUTES (new_node->decl));
DECL_ATTRIBUTES (new_node->decl) = attributes;
+ location_t saved_loc = input_location;
+ input_location = DECL_SOURCE_LOCATION (node->decl);
if (!targetm.target_option.valid_attribute_p (new_node->decl, NULL,
- TREE_VALUE (attributes), 0))
+ TREE_VALUE (attributes),
+ 0))
{
- warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
- "attribute(target_clones(\"%s\")) is not "
- "valid for current target", attr);
+ input_location = saved_loc;
continue;
}
+ input_location = saved_loc;
decl2_v = new_node->function_version ();
if (decl2_v != NULL)
continue;
DECL_FUNCTION_VERSIONED (new_node->decl) = 1;
}
- /* Setting new attribute to initial function. */
- tree attributes = make_attribute ("target", "default",
- DECL_ATTRIBUTES (node->decl));
- DECL_ATTRIBUTES (node->decl) = attributes;
- if (!targetm.target_option.valid_attribute_p (node->decl, NULL,
- TREE_VALUE (attributes), 0))
- {
- error_at (DECL_SOURCE_LOCATION (node->decl),
- "attribute(target_clones(\"default\")) is not "
- "valid for current target");
- return false;
- }
-
XDELETEVEC (attrs);
XDELETEVEC (attr_str);
- return true;
+
+ /* Setting new attribute to initial function. */
+ tree attributes = make_attribute ("target", "default",
+ DECL_ATTRIBUTES (node->decl));
+ DECL_ATTRIBUTES (node->decl) = attributes;
+ location_t saved_loc = input_location;
+ input_location = DECL_SOURCE_LOCATION (node->decl);
+ bool ret
+ = targetm.target_option.valid_attribute_p (node->decl, NULL,
+ TREE_VALUE (attributes), 0);
+ input_location = saved_loc;
+ return ret;
}
static bool target_clone_pass;