aboutsummaryrefslogtreecommitdiff
path: root/gcc/multiple_target.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-04-12 14:54:00 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-04-12 12:54:00 +0000
commita164374ef13853b25de2ad205d765fe8200bf128 (patch)
treeafe7b2db0d2c7bdc4b779ccf3ef8dcf974baf746 /gcc/multiple_target.c
parent34f02c07fb1a9d966fb7af5a8c28c213e84d89c5 (diff)
downloadgcc-a164374ef13853b25de2ad205d765fe8200bf128.zip
gcc-a164374ef13853b25de2ad205d765fe8200bf128.tar.gz
gcc-a164374ef13853b25de2ad205d765fe8200bf128.tar.bz2
Handle multiple 'default' in target attribute (PR middle-end/89970).
2019-04-12 Martin Liska <mliska@suse.cz> PR middle-end/89970 * multiple_target.c (create_dispatcher_calls): Wrap ifunc in error message. (separate_attrs): Handle multiple 'default's. (expand_target_clones): Rework error handling code. 2019-04-12 Martin Liska <mliska@suse.cz> PR middle-end/89970 * gcc.target/i386/mvc15.c: New test. * gcc.target/i386/mvc3.c: Quote target in error pattern. * gcc.target/i386/mvc4.c: Remove duplicit 'default'. From-SVN: r270314
Diffstat (limited to 'gcc/multiple_target.c')
-rw-r--r--gcc/multiple_target.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index fd983cc..0a87241 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -73,7 +73,7 @@ create_dispatcher_calls (struct cgraph_node *node)
if (!targetm.has_ifunc_p ())
{
error_at (DECL_SOURCE_LOCATION (node->decl),
- "the call requires ifunc, which is not"
+ "the call requires %<ifunc%>, which is not"
" supported by this target");
return;
}
@@ -235,8 +235,10 @@ get_attr_str (tree arglist, char *attr_str)
}
/* Return number of attributes separated by comma and put them into ARGS.
- If there is no DEFAULT attribute return -1. If there is an empty
- string in attribute return -2. */
+ If there is no DEFAULT attribute return -1.
+ If there is an empty string in attribute return -2.
+ If there are multiple DEFAULT attributes return -3.
+ */
static int
separate_attrs (char *attr_str, char **attrs, int attrnum)
@@ -256,6 +258,8 @@ separate_attrs (char *attr_str, char **attrs, int attrnum)
}
if (default_count == 0)
return -1;
+ else if (default_count > 1)
+ return -3;
else if (i + default_count < attrnum)
return -2;
@@ -347,8 +351,7 @@ expand_target_clones (struct cgraph_node *node, bool definition)
if (attr_len == -1)
{
warning_at (DECL_SOURCE_LOCATION (node->decl),
- 0,
- "single %<target_clones%> attribute is ignored");
+ 0, "single %<target_clones%> attribute is ignored");
return false;
}
@@ -374,18 +377,26 @@ expand_target_clones (struct cgraph_node *node, bool definition)
char **attrs = XNEWVEC (char *, attrnum);
attrnum = separate_attrs (attr_str, attrs, attrnum);
- if (attrnum == -1)
+ switch (attrnum)
{
+ case -1:
error_at (DECL_SOURCE_LOCATION (node->decl),
- "default target was not set");
- XDELETEVEC (attrs);
- XDELETEVEC (attr_str);
- return false;
- }
- else if (attrnum == -2)
- {
+ "%<default%> target was not set");
+ break;
+ case -2:
error_at (DECL_SOURCE_LOCATION (node->decl),
"an empty string cannot be in %<target_clones%> attribute");
+ break;
+ case -3:
+ error_at (DECL_SOURCE_LOCATION (node->decl),
+ "multiple %<default%> targets were set");
+ break;
+ default:
+ break;
+ }
+
+ if (attrnum < 0)
+ {
XDELETEVEC (attrs);
XDELETEVEC (attr_str);
return false;