public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr
@ 2021-10-18 11:21 Prathamesh Kulkarni
  2021-10-19 14:28 ` Richard Sandiford
  0 siblings, 1 reply; 12+ messages in thread
From: Prathamesh Kulkarni @ 2021-10-18 11:21 UTC (permalink / raw)
  To: gcc Patches, Martin Liška, Richard Sandiford

[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

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

[-- Attachment #2: 102376-1.txt --]
[-- Type: text/plain, Size: 828 bytes --]

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;
 	}
 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-11-11  9:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 11:21 [aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr Prathamesh Kulkarni
2021-10-19 14:28 ` Richard Sandiford
2021-10-20  7:08   ` Prathamesh Kulkarni
2021-10-20  9:35     ` Richard Sandiford
2021-10-22  9:11       ` Prathamesh Kulkarni
2021-10-28  8:59         ` Prathamesh Kulkarni
2021-10-28 16:03           ` Martin Sebor
2021-11-04  7:04             ` Prathamesh Kulkarni
2021-11-04  8:49         ` Richard Sandiford
2021-11-08 10:33           ` Prathamesh Kulkarni
2021-11-09 14:57             ` Richard Sandiford
2021-11-11  9:15               ` Prathamesh Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).