From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>
Subject: Ping2: [PATCH] Fix parser to recognize operator?:
Date: Wed, 06 Nov 2019 14:44:00 -0000 [thread overview]
Message-ID: <2773167.W5LUESqpdP@minbar> (raw)
In-Reply-To: <5577075.BzrJHIBtfX@depc447>
ping2
On Montag, 14. Oktober 2019 12:27:11 CET Matthias Kretz wrote:
> This time with testcase. Is the subdir for the test ok?
>
> gcc/ChangeLog:
>
> 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.
>
> gcc/testsuite/ChangeLog:
>
> 2019-10-14 Matthias Kretz <m.kretz@gsi.de>
> * testsuite/g++.dg/parse/operator9.C: New test verifying the
> correct error message is printed.
>
> 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 `('. */
> diff --git a/gcc/testsuite/g++.dg/parse/operator9.C b/gcc/testsuite/g++.dg/
> parse/operator9.C
> new file mode 100644
> index 00000000000..d66355afab5
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/parse/operator9.C
> @@ -0,0 +1,5 @@
> +// { dg-do compile }
> +
> +struct A {};
> +struct B {};
> +int operator?:(bool, A, B); // { dg-error "prohibits overloading" }
>
> On Freitag, 11. Oktober 2019 16:17:09 CEST you wrote:
> > 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.
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtzzentrum für Schwerionenforschung https://gsi.de
SIMD easy and portable https://github.com/VcDevel/Vc
──────────────────────────────────────────────────────────────────────────
next prev parent reply other threads:[~2019-11-06 14:44 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
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 ` Matthias Kretz [this message]
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=2773167.W5LUESqpdP@minbar \
--to=m.kretz@gsi.de \
--cc=gcc-patches@gcc.gnu.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).