From: Richard Biener <richard.guenther@gmail.com>
To: Mikhail Maltsev <maltsevm@gmail.com>
Cc: gcc-patches <gcc-patches@gnu.org>,
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Subject: Re: [PATCH 1/5][GIMPLE FE] PR testsuite/80580. Handle missing labels in goto statements
Date: Tue, 02 May 2017 14:21:00 -0000 [thread overview]
Message-ID: <CAFiYyc39p1ZhzAHXAtj68UchFNG6fbjAoYZSQatJTVRBTOrCig@mail.gmail.com> (raw)
In-Reply-To: <9e3b3ee6-0c67-f974-c38e-7f9f25249914@gmail.com>
On Mon, May 1, 2017 at 8:04 PM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> The first problem happens because we don't check for missing labels when parsing
> 'goto' statements. I.e.:
>
> __GIMPLE() void fn1() {
> if (1)
> goto
> }
>
> The fix is pretty obvious: just add a check.
> My question is: which functions should I use to produce diagnostics? The
> surrounding code uses 'c_parser_error', but this function does not handle
> locations very well (in fact, it uses input_location).
Certainly an improvement. I suppose we can do better error recovery
for cases like
if (1)
goto
else
goto bar;
but I guess this is better than nothing.
And yes, we use c_parser_error -- input_location should be ok but here
we just peek which may upset the parser. Maybe it works better
when consuming the token before issueing the error? Thus
Index: gcc/c/gimple-parser.c
===================================================================
--- gcc/c/gimple-parser.c (revision 247498)
+++ gcc/c/gimple-parser.c (working copy)
@@ -1315,8 +1315,8 @@ c_parser_gimple_if_stmt (c_parser *parse
loc = c_parser_peek_token (parser)->location;
c_parser_consume_token (parser);
label = c_parser_peek_token (parser)->value;
- t_label = lookup_label_for_goto (loc, label);
c_parser_consume_token (parser);
+ t_label = lookup_label_for_goto (loc, label);
if (! c_parser_require (parser, CPP_SEMICOLON, "expected %<;%>"))
return;
}
?
Patch is ok with or without this adjustment (and testcase adjustment).
Thanks,
Richard.
> --
> Regards,
> Mikhail Maltsev
>
> gcc/testsuite/ChangeLog:
>
> 2017-05-01 Mikhail Maltsev <maltsevm@gmail.com>
>
> * gcc.dg/gimplefe-error-4.c: New test.
> * gcc.dg/gimplefe-error-5.c: New test.
>
>
> gcc/c/ChangeLog:
>
> 2017-05-01 Mikhail Maltsev <maltsevm@gmail.com>
>
> * gimple-parser.c (c_parser_gimple_if_stmt): Check for empty labels.
>
>
next prev parent reply other threads:[~2017-05-02 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-01 18:04 Mikhail Maltsev
2017-05-02 14:21 ` Richard Biener [this message]
2017-05-29 5:04 ` Mikhail Maltsev
2017-05-30 11:47 ` Richard Biener
2017-05-30 11:50 ` Richard Biener
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=CAFiYyc39p1ZhzAHXAtj68UchFNG6fbjAoYZSQatJTVRBTOrCig@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gnu.org \
--cc=maltsevm@gmail.com \
--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).