From: Marek Polacek <polacek@redhat.com>
To: Matthias Kretz <m.kretz@gsi.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix parser to recognize operator?:
Date: Fri, 11 Oct 2019 14:17:00 -0000 [thread overview]
Message-ID: <20191011141709.GN2949@redhat.com> (raw)
In-Reply-To: <3763881.t63Sp36aLF@depc447>
On Fri, Oct 11, 2019 at 04:06:43PM +0200, Matthias Kretz wrote:
> This is a minor bugfix for improved error reporting. Overloading ?: is just as
> disallowed as it is without this change.
Thanks. Can you provide a testcase that shows why this change makes sense?
That testcase then should be part of the patch submission.
> 2019-10-11 Matthias Kretz <m.kretz@gsi.de>
>
> * gcc/cp/parser.c (cp_parser_operator): Parse operator?: as an
> attempt to overload the conditional operator. Then
> grok_op_properties can print its useful "ISO C++ prohibits
> overloading operator ?:" message instead of the cryptic error
> message about a missing type-specifier before '?' token.
>
> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
> index 3ee8da7db94..73385cb3dcb 100644
> --- a/gcc/cp/parser.c
> +++ b/gcc/cp/parser.c
> @@ -15502,6 +15502,15 @@ cp_parser_operator (cp_parser* parser, location_t
> start_loc)
> op = COMPONENT_REF;
> break;
>
> + case CPP_QUERY:
> + op = COND_EXPR;
> + /* Consume the `?'. */
> + cp_lexer_consume_token (parser->lexer);
> + /* Look for the matching `:'. */
> + cp_parser_require (parser, CPP_COLON, RT_COLON);
> + consumed = true;
> + break;
> +
> case CPP_OPEN_PAREN:
> {
> /* Consume the `('. */
--
Marek Polacek ⢠Red Hat, Inc. ⢠300 A St, Boston, MA
next prev parent reply other threads:[~2019-10-11 14:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-11 14:14 Matthias Kretz
2019-10-11 14:17 ` Marek Polacek [this message]
2019-10-14 8:29 ` Matthias Kretz
2019-10-14 10:35 ` Matthias Kretz
2019-10-24 9:12 ` Dr. Matthias Kretz
2019-11-06 14:44 ` Ping2: " Matthias Kretz
2019-11-06 16:07 ` Jason Merrill
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=20191011141709.GN2949@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=m.kretz@gsi.de \
/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).