public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Cc: "gcc Patches" <gcc-patches@gcc.gnu.org>, "Martin Liška" <mliska@suse.cz>
Subject: Re: [aarch64] PR102376 - Emit better diagnostic for arch extensions in target attr
Date: Tue, 19 Oct 2021 15:28:16 +0100	[thread overview]
Message-ID: <mpty26p2inz.fsf@arm.com> (raw)
In-Reply-To: <CAAgBjMmAWeRqHtWtzuvBtFpd5btXY7R71uEGAZYt4ydVuWqStQ@mail.gmail.com> (Prathamesh Kulkarni's message of "Mon, 18 Oct 2021 16:51:03 +0530")

Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes:
> 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")));
>       | ^~~~

Nice :-)

> (This isn't specific to sve though).
> OK to commit after bootstrap+test ?
>
> Thanks,
> Prathamesh
>
> 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);

I think std::string would be better here, e.g.:

  auto with_plus = std::string ("+") + token;

> +	  if (aarch64_handle_attr_isa_flags (str))
> +	    error("arch extension %<%s%> should be prepended with %<+%>", token);

Nit: should be a space before the “(”.

In principle, a fixit hint would have been nice here, but I don't think
we have enough information to provide one.  (Just saying for the record.)

Thanks,
Richard

> +	  else
> +	    error ("pragma or attribute %<target(\"%s\")%> is not valid", token);
> +	  free (str);
>  	  return false;
>  	}
>  

  reply	other threads:[~2021-10-19 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 11:21 Prathamesh Kulkarni
2021-10-19 14:28 ` Richard Sandiford [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpty26p2inz.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mliska@suse.cz \
    --cc=prathamesh.kulkarni@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).