public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches@gcc.gnu.org, jakub@redhat.com,
	       Joseph Myers <joseph@codesourcery.com>,
	nathan@acm.org,        polacek@redhat.com
Subject: Re: [PATCH 1/2] asm qualifiers (PR55681)
Date: Wed, 05 Dec 2018 23:02:00 -0000	[thread overview]
Message-ID: <20181205230213.GV3803@gate.crashing.org> (raw)
In-Reply-To: <0f5fe39e-4061-1b0b-bb5c-3676f395bff6@redhat.com>

Hi!

On Wed, Dec 05, 2018 at 04:47:37PM -0500, Jason Merrill wrote:
> On 12/2/18 11:38 AM, Segher Boessenkool wrote:
> >PR55681 observes that currently only one qualifier is allowed for
> >inline asm, so that e.g. "volatile asm" is allowed, "const asm" is also
> >okay (with a warning), but "const volatile asm" gives an error.  Also
> >"goto" has to be last.
> >
> >This patch changes things so that only "asm-qualifiers" are allowed,
> >that is "volatile" and "goto", in any combination, in any order, but
> >without repetitions.
> >
> >
> >2018-12-02  Segher Boessenkool  <segher@kernel.crashing.org>
> >
> >	PR inline-asm/55681
> >	* doc/extend.texi (Basic Asm): Update grammar.
> >	(Extended Asm): Update grammar.
> >
> >gcc/c/
> >	PR inline-asm/55681
> >	* c-parser.c (c_parser_for_statement): Update grammar.  Allow any
> >	combination of volatile and goto, in any order, without repetitions.
> >
> >gcc/cp/
> >	PR inline-asm/55681
> >	* parser.c (cp_parser_using_directive): Update grammar.  Allow any
> >	combination of volatile and goto, in any order, without repetitions.
> 
> You don't actually change cp_parser_using_directive, despite what diff 
> says: you're changing cp_parser_asm_definition.

I trust diff too much, sigh.

> >+    for (bool done = false; !done ; )
> >+      switch (cp_lexer_peek_token (parser->lexer)->keyword)
> >+	{
> >+	case RID_VOLATILE:
> >+	  if (!volatile_p)
> >+	    {
> >+	      /* Remember that we saw the `volatile' keyword.  */
> >+	      volatile_p = true;
> >+	      /* Consume the token.  */
> >+	      cp_lexer_consume_token (parser->lexer);
> >+	    }
> >+	  else
> >+	    done = true;
> >+	  break;
> >+	case RID_GOTO:
> >+	  if (!goto_p && parser->in_function_body)
> >+	    {
> >+	      /* Remember that we saw the `goto' keyword.  */
> >+	      goto_p = true;
> >+	      /* Consume the token.  */
> >+	      cp_lexer_consume_token (parser->lexer);
> >+	    }
> >+	  else
> >+	    done = true;
> >+	  break;
> >+	default:
> >+	  done = true;
> >+	}
> 
> An arguably simpler alternative to using the 'done' variable would be to 
> 'break' out of the loop after the switch, and have the consume_token 
> cases explicitly 'continue'.

Yeah, that is neater, continue only deals with the loop.  Nice.

> We also might remember the old tokens and give a more helpful error 
> message in the case of duplicate keywords.
> 
> But I won't insist on either of these, the C++ changes are OK as-is.

I'll commit it like this then, and work on the improvements afterwards
(they also apply to the C frontend).

Thanks for the review!


Segher

  reply	other threads:[~2018-12-05 23:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-02 16:38 [PATCH v2 0/2] asm qualifiers (PR55681) and asm inline Segher Boessenkool
2018-12-02 16:39 ` [PATCH 1/2] asm qualifiers (PR55681) Segher Boessenkool
2018-12-03 22:20   ` Joseph Myers
2018-12-05 21:47   ` Jason Merrill
2018-12-05 23:02     ` Segher Boessenkool [this message]
2018-12-02 16:40 ` [PATCH 2/2] asm inline Segher Boessenkool
2018-12-02 17:23   ` Marc Glisse
2018-12-02 17:45     ` Segher Boessenkool
2018-12-02 18:38       ` Marc Glisse
2018-12-04 15:31   ` Richard Sandiford
2018-12-06  3:03     ` Segher Boessenkool
2018-12-06 18:11 ` [PATCH v2 0/2] asm qualifiers (PR55681) and " Segher Boessenkool
2018-12-06 18:15   ` Jakub Jelinek
2018-12-06 18:19     ` Joseph Myers
2018-12-06 18:54     ` Segher Boessenkool
  -- strict thread matches above, loose matches on Subject: below --
2018-10-30 18:01 [PATCH 0/2] asm qualifiers (PR55681) and asm input Segher Boessenkool
2018-10-30 18:56 ` [PATCH 1/2] asm qualifiers (PR55681) Segher Boessenkool
2018-11-29 13:35   ` Segher Boessenkool
2018-11-29 21:13     ` Joseph Myers
2018-11-29 22:22       ` Segher Boessenkool
2018-11-29 23:14         ` Joseph Myers
2018-11-30  0:03           ` Segher Boessenkool
2018-11-30  0:11             ` Joseph Myers
2018-11-30  0:21               ` Segher Boessenkool

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=20181205230213.GV3803@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nathan@acm.org \
    --cc=polacek@redhat.com \
    /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).