https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81224

--- Comment #19 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Liška from comment #18)
> (In reply to Jakub Jelinek from comment #17)
> > (In reply to Martin Liška from comment #16)
> > > --- a/gcc/c-family/c-common.c
> > > +++ b/gcc/c-family/c-common.c
> > > @@ -9447,7 +9447,6 @@ handle_target_attribute (tree *node, tree name, tree
> > > args, int flags,
> > >     && TREE_STRING_LENGTH (value) == 1
> > >     && TREE_STRING_POINTER (value)[0] == '\0')
> > >   {
> > > -   warning (OPT_Wattributes, "empty string in attribute %<target%>");
> > >     *no_add_attrs = true;
> > >   }
> > >      }
> > > 
> > > That will however skip entire attribute:
> > > __attribute__((target("sse4.2", "", "")))
> > > 
> > > Or I can do patch that will just remove empty strings in a TREE_LIST.
> > > What way do you prefer?
> > 
> > Something that doesn't change behavior.  So the latter is better than the
> > former, but I wonder if just some return or continue when seeing empty
> > string later on isn't even easier/safer.
> 
> Well, for this purpose, maybe the original patch can be handy:
> https://patchwork.ozlabs.org/patch/794801/ ?

This one works for some situations, however it's quite painful to handle it
properly, for instance:

$ cat /tmp/ice.C
__attribute__((target("default")))
int foo() {return 99;}
__attribute__((target("sse4.2","")))
int foo() {return 1;}
__attribute__((target("","")))
int foo() {return 1;}

int main() {
    return foo();
}

$ ./xg++ -B. /tmp/ice.C -S -c
/tmp/ice.C: In function ‘<built-in>’:
/tmp/ice.C:6:5: error: No dispatcher found for the versioning attributes : 
 int foo() {return 1;}
     ^~~

Reply via email to