On 03/14/2017 12:09 PM, Richard Biener wrote: > On Tue, Mar 14, 2017 at 11:24 AM, Martin Liška <mli...@suse.cz> wrote: >> Hello. >> >> This fixes ICE when one does not provide valid target names: >> __attribute__((target_clones("default,foo,bar"))) >> >> In that situation I suggest to print: >> >> $ ./xgcc -B. /tmp/mvc-ice.c >> /tmp/mvc-ice.c:6:1: error: attribute(target("foo")) is unknown >> foo () >> ^~~ >> /tmp/mvc-ice.c:6:1: error: attribute(target("bar")) is unknown >> /tmp/mvc-ice.c: In function ‘foo.resolver’: >> cc1: fatal error: At least one more version other than the default is >> expected >> >> Should I add a test-case for a fatal error? > > Better avoid fatal_error, can't you just return early after regular error()?
Yep. Early bail out would be better. > > Do we error similarly for __attribute__((target_clones("default"))) > from generic code? > > I wonder if we can just go ahead even with num_versions == 1? It's covered in MV pass: $ ./xgcc -B. /tmp/mvc-single.c /tmp/mvc-single.c:6:1: warning: single target_clones attribute is ignored foo () Martin > > >> >> Thanks, >> Martin
>From 5e7aa55549fabeb4c7fc4b8339dba210c49614d0 Mon Sep 17 00:00:00 2001 From: marxin <mli...@suse.cz> Date: Tue, 14 Mar 2017 11:16:51 +0100 Subject: [PATCH] Do not ICE on an invalid input for MV. gcc/ChangeLog: 2017-03-14 Martin Liska <mli...@suse.cz> * multiple_target.c (expand_target_clones): Bail out for an invalid attribute. --- gcc/multiple_target.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c index 7b735ae81ae..1e02116a2db 100644 --- a/gcc/multiple_target.c +++ b/gcc/multiple_target.c @@ -296,10 +296,7 @@ expand_target_clones (struct cgraph_node *node, bool definition) if (!targetm.target_option.valid_attribute_p (new_node->decl, NULL, TREE_VALUE (attributes), 0)) - { - input_location = saved_loc; - continue; - } + return false; input_location = saved_loc; decl2_v = new_node->function_version (); -- 2.11.1