* C++ PATCH to fix ICE with invalid cast (PR c++/84493)
@ 2018-02-21 10:36 Marek Polacek
2018-02-21 21:50 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2018-02-21 10:36 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
Here we can prevent a crash on invalid by using require_open where '{' is
expected. require_open uses cp_parser_require whereas consume_open has
an assert:
gcc_assert (tok->type == traits_t::open_token_type);
which triggers here.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2018-02-21 Marek Polacek <polacek@redhat.com>
PR c++/84493
* parser.c (cp_parser_braced_list): Use require_open instead of
consume_open.
* g++.dg/parse/error59.C: New test.
diff --git gcc/cp/parser.c gcc/cp/parser.c
index 2bb0d2da5fe..4fa546a086c 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -21925,7 +21925,7 @@ cp_parser_braced_list (cp_parser* parser, bool* non_constant_p)
/* Consume the `{' token. */
matching_braces braces;
- braces.consume_open (parser);
+ braces.require_open (parser);
/* Create a CONSTRUCTOR to represent the braced-initializer. */
initializer = make_node (CONSTRUCTOR);
/* If it's not a `}', then there is a non-trivial initializer. */
diff --git gcc/testsuite/g++.dg/parse/error59.C gcc/testsuite/g++.dg/parse/error59.C
index e69de29bb2d..2c44e210366 100644
--- gcc/testsuite/g++.dg/parse/error59.C
+++ gcc/testsuite/g++.dg/parse/error59.C
@@ -0,0 +1,6 @@
+// PR c++/84493
+
+void foo()
+{
+ (struct {}x){}; // { dg-error "" }
+}
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH to fix ICE with invalid cast (PR c++/84493)
2018-02-21 10:36 C++ PATCH to fix ICE with invalid cast (PR c++/84493) Marek Polacek
@ 2018-02-21 21:50 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-02-21 21:50 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
OK.
On Wed, Feb 21, 2018 at 5:36 AM, Marek Polacek <polacek@redhat.com> wrote:
> Here we can prevent a crash on invalid by using require_open where '{' is
> expected. require_open uses cp_parser_require whereas consume_open has
> an assert:
> gcc_assert (tok->type == traits_t::open_token_type);
> which triggers here.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-02-21 Marek Polacek <polacek@redhat.com>
>
> PR c++/84493
> * parser.c (cp_parser_braced_list): Use require_open instead of
> consume_open.
>
> * g++.dg/parse/error59.C: New test.
>
> diff --git gcc/cp/parser.c gcc/cp/parser.c
> index 2bb0d2da5fe..4fa546a086c 100644
> --- gcc/cp/parser.c
> +++ gcc/cp/parser.c
> @@ -21925,7 +21925,7 @@ cp_parser_braced_list (cp_parser* parser, bool* non_constant_p)
>
> /* Consume the `{' token. */
> matching_braces braces;
> - braces.consume_open (parser);
> + braces.require_open (parser);
> /* Create a CONSTRUCTOR to represent the braced-initializer. */
> initializer = make_node (CONSTRUCTOR);
> /* If it's not a `}', then there is a non-trivial initializer. */
> diff --git gcc/testsuite/g++.dg/parse/error59.C gcc/testsuite/g++.dg/parse/error59.C
> index e69de29bb2d..2c44e210366 100644
> --- gcc/testsuite/g++.dg/parse/error59.C
> +++ gcc/testsuite/g++.dg/parse/error59.C
> @@ -0,0 +1,6 @@
> +// PR c++/84493
> +
> +void foo()
> +{
> + (struct {}x){}; // { dg-error "" }
> +}
>
> Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-21 21:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 10:36 C++ PATCH to fix ICE with invalid cast (PR c++/84493) Marek Polacek
2018-02-21 21:50 ` Jason Merrill
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).