[aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr
Prathamesh Kulkarni
prathamesh.kulkarni@linaro.org
Mon Oct 18 11:21:03 GMT 2021
Hi,
The attached patch emits a more verbose diagnostic for target attribute that
is an architecture extension needing a leading '+'.
For the following test,
void calculate(void) __attribute__ ((__target__ ("sve")));
With patch, the compiler now emits:
102376.c:1:1: error: arch extension ‘sve’ should be prepended with ‘+’
1 | void calculate(void) __attribute__ ((__target__ ("sve")));
| ^~~~
instead of:
102376.c:1:1: error: pragma or attribute ‘target("sve")’ is not valid
1 | void calculate(void) __attribute__ ((__target__ ("sve")));
| ^~~~
(This isn't specific to sve though).
OK to commit after bootstrap+test ?
Thanks,
Prathamesh
-------------- next part --------------
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a9a1800af53..975f7faf968 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -17821,7 +17821,16 @@ aarch64_process_target_attr (tree args)
num_attrs++;
if (!aarch64_process_one_target_attr (token))
{
- error ("pragma or attribute %<target(\"%s\")%> is not valid", token);
+ /* Check if token is possibly an arch extension without
+ leading '+'. */
+ char *str = (char *) xmalloc (strlen (token) + 2);
+ str[0] = '+';
+ strcpy(str + 1, token);
+ if (aarch64_handle_attr_isa_flags (str))
+ error("arch extension %<%s%> should be prepended with %<+%>", token);
+ else
+ error ("pragma or attribute %<target(\"%s\")%> is not valid", token);
+ free (str);
return false;
}
More information about the Gcc-patches
mailing list