* [COMMITTED] c++: Fix ICE on nonsense requires-clause.
@ 2020-02-07 13:54 Jason Merrill
2020-02-10 13:13 ` Christophe Lyon
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2020-02-07 13:54 UTC (permalink / raw)
To: gcc-patches
Here we were swallowing all the syntax errors by parsing tentatively, and
returning error_mark_node without ever actually giving an error. Fixed by
using save_tokens/rollback_tokens instead.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/92517
* parser.c (cp_parser_constraint_primary_expression): Do the main
parse non-tentatively.
---
gcc/cp/parser.c | 17 +++++++----------
gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C | 9 +++++++++
2 files changed, 16 insertions(+), 10 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e0f72302e5e..d4c9523289f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -27478,7 +27478,7 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p)
return e;
}
- cp_parser_parse_tentatively (parser);
+ cp_lexer_save_tokens (parser->lexer);
cp_id_kind idk;
location_t loc = input_location;
cp_expr expr = cp_parser_primary_expression (parser,
@@ -27494,19 +27494,16 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p)
/* The primary-expression could be part of an unenclosed non-logical
compound expression. */
pce = cp_parser_constraint_requires_parens (parser, lambda_p);
- if (pce != pce_ok)
- cp_parser_simulate_error (parser);
- else
- expr = finish_constraint_primary_expr (expr);
}
- if (cp_parser_parse_definitely (parser))
- return expr;
- if (expr == error_mark_node)
- return error_mark_node;
+ if (pce == pce_ok)
+ {
+ cp_lexer_commit_tokens (parser->lexer);
+ return finish_constraint_primary_expr (expr);
+ }
/* Retry the parse at a lower precedence. If that succeeds, diagnose the
error, but return the expression as if it were valid. */
- gcc_assert (pce != pce_ok);
+ cp_lexer_rollback_tokens (parser->lexer);
cp_parser_parse_tentatively (parser);
if (pce == pce_maybe_operator)
expr = cp_parser_assignment_expression (parser, NULL, false, false);
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
new file mode 100644
index 00000000000..0a47682c456
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
@@ -0,0 +1,9 @@
+// PR c++/92517
+// { dg-do compile { target concepts } }
+
+template <typename T>
+concept C = true;
+
+template<int I>
+requires C decltype<I> // { dg-error "" }
+void f() {}
base-commit: 3c7a03bc360c3511fae3747a71e579e9fd0824f9
--
2.18.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COMMITTED] c++: Fix ICE on nonsense requires-clause.
2020-02-07 13:54 [COMMITTED] c++: Fix ICE on nonsense requires-clause Jason Merrill
@ 2020-02-10 13:13 ` Christophe Lyon
2020-02-10 13:53 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Christophe Lyon @ 2020-02-10 13:13 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc Patches
On Fri, 7 Feb 2020 at 14:54, Jason Merrill <jason@redhat.com> wrote:
>
> Here we were swallowing all the syntax errors by parsing tentatively, and
> returning error_mark_node without ever actually giving an error. Fixed by
> using save_tokens/rollback_tokens instead.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
>
> PR c++/92517
> * parser.c (cp_parser_constraint_primary_expression): Do the main
> parse non-tentatively.
> ---
> gcc/cp/parser.c | 17 +++++++----------
> gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C | 9 +++++++++
> 2 files changed, 16 insertions(+), 10 deletions(-)
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
>
Hi,
This patch is causing several regressions on arm and aarch64.
For instance on aarch64:
FAIL: g++.dg/vect/pr89653.cc -std=c++2a (test for excess errors)
Excess errors:
/aarch64-none-linux-gnu/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
error: expected primary-expression before '&&' token
and on arm:
FAIL: g++.dg/cpp0x/lambda/lambda-pass.C -std=c++2a (test for excess errors)
Excess errors:
/arm-none-linux-gnueabi/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
error: expected primary-expression before '&&' token
Christophe
> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
> index e0f72302e5e..d4c9523289f 100644
> --- a/gcc/cp/parser.c
> +++ b/gcc/cp/parser.c
> @@ -27478,7 +27478,7 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p)
> return e;
> }
>
> - cp_parser_parse_tentatively (parser);
> + cp_lexer_save_tokens (parser->lexer);
> cp_id_kind idk;
> location_t loc = input_location;
> cp_expr expr = cp_parser_primary_expression (parser,
> @@ -27494,19 +27494,16 @@ cp_parser_constraint_primary_expression (cp_parser *parser, bool lambda_p)
> /* The primary-expression could be part of an unenclosed non-logical
> compound expression. */
> pce = cp_parser_constraint_requires_parens (parser, lambda_p);
> - if (pce != pce_ok)
> - cp_parser_simulate_error (parser);
> - else
> - expr = finish_constraint_primary_expr (expr);
> }
> - if (cp_parser_parse_definitely (parser))
> - return expr;
> - if (expr == error_mark_node)
> - return error_mark_node;
> + if (pce == pce_ok)
> + {
> + cp_lexer_commit_tokens (parser->lexer);
> + return finish_constraint_primary_expr (expr);
> + }
>
> /* Retry the parse at a lower precedence. If that succeeds, diagnose the
> error, but return the expression as if it were valid. */
> - gcc_assert (pce != pce_ok);
> + cp_lexer_rollback_tokens (parser->lexer);
> cp_parser_parse_tentatively (parser);
> if (pce == pce_maybe_operator)
> expr = cp_parser_assignment_expression (parser, NULL, false, false);
> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
> new file mode 100644
> index 00000000000..0a47682c456
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
> @@ -0,0 +1,9 @@
> +// PR c++/92517
> +// { dg-do compile { target concepts } }
> +
> +template <typename T>
> +concept C = true;
> +
> +template<int I>
> +requires C decltype<I> // { dg-error "" }
> +void f() {}
>
> base-commit: 3c7a03bc360c3511fae3747a71e579e9fd0824f9
> --
> 2.18.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COMMITTED] c++: Fix ICE on nonsense requires-clause.
2020-02-10 13:13 ` Christophe Lyon
@ 2020-02-10 13:53 ` Jason Merrill
2020-02-10 14:39 ` Christophe Lyon
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2020-02-10 13:53 UTC (permalink / raw)
To: Christophe Lyon; +Cc: gcc Patches
On Mon, Feb 10, 2020 at 2:13 PM Christophe Lyon <christophe.lyon@linaro.org>
wrote:
> On Fri, 7 Feb 2020 at 14:54, Jason Merrill <jason@redhat.com> wrote:
> >
> > Here we were swallowing all the syntax errors by parsing tentatively, and
> > returning error_mark_node without ever actually giving an error. Fixed
> by
> > using save_tokens/rollback_tokens instead.
> >
> > Tested x86_64-pc-linux-gnu, applying to trunk.
> >
> > PR c++/92517
> > * parser.c (cp_parser_constraint_primary_expression): Do the main
> > parse non-tentatively.
> > ---
> > gcc/cp/parser.c | 17 +++++++----------
> > gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C | 9 +++++++++
> > 2 files changed, 16 insertions(+), 10 deletions(-)
> > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
> >
>
> Hi,
>
> This patch is causing several regressions on arm and aarch64.
>
> For instance on aarch64:
> FAIL: g++.dg/vect/pr89653.cc -std=c++2a (test for excess errors)
> Excess errors:
> /aarch64-none-linux-gnu/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
> error: expected primary-expression before '&&' token
>
> and on arm:
> FAIL: g++.dg/cpp0x/lambda/lambda-pass.C -std=c++2a (test for excess
> errors)
> Excess errors:
> /arm-none-linux-gnueabi/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
> error: expected primary-expression before '&&' token
>
> Christophe
>
This is fixed in r10-6512-ga04f635d1e4df9679caf763f744eb41a938468f4
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COMMITTED] c++: Fix ICE on nonsense requires-clause.
2020-02-10 13:53 ` Jason Merrill
@ 2020-02-10 14:39 ` Christophe Lyon
0 siblings, 0 replies; 4+ messages in thread
From: Christophe Lyon @ 2020-02-10 14:39 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc Patches
On Mon, 10 Feb 2020 at 14:53, Jason Merrill <jason@redhat.com> wrote:
>
> On Mon, Feb 10, 2020 at 2:13 PM Christophe Lyon <christophe.lyon@linaro.org> wrote:
>>
>> On Fri, 7 Feb 2020 at 14:54, Jason Merrill <jason@redhat.com> wrote:
>> >
>> > Here we were swallowing all the syntax errors by parsing tentatively, and
>> > returning error_mark_node without ever actually giving an error. Fixed by
>> > using save_tokens/rollback_tokens instead.
>> >
>> > Tested x86_64-pc-linux-gnu, applying to trunk.
>> >
>> > PR c++/92517
>> > * parser.c (cp_parser_constraint_primary_expression): Do the main
>> > parse non-tentatively.
>> > ---
>> > gcc/cp/parser.c | 17 +++++++----------
>> > gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C | 9 +++++++++
>> > 2 files changed, 16 insertions(+), 10 deletions(-)
>> > create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-syntax1.C
>> >
>>
>> Hi,
>>
>> This patch is causing several regressions on arm and aarch64.
>>
>> For instance on aarch64:
>> FAIL: g++.dg/vect/pr89653.cc -std=c++2a (test for excess errors)
>> Excess errors:
>> /aarch64-none-linux-gnu/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
>> error: expected primary-expression before '&&' token
>>
>> and on arm:
>> FAIL: g++.dg/cpp0x/lambda/lambda-pass.C -std=c++2a (test for excess errors)
>> Excess errors:
>> /arm-none-linux-gnueabi/libstdc++-v3/include/bits/ranges_algo.h:1254:4:
>> error: expected primary-expression before '&&' token
>>
>> Christophe
>
>
> This is fixed in r10-6512-ga04f635d1e4df9679caf763f744eb41a938468f4
>
Thanks. Sorry for missing it, but I understand why when I read the
commit message ;-)
> Jason
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-10 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 13:54 [COMMITTED] c++: Fix ICE on nonsense requires-clause Jason Merrill
2020-02-10 13:13 ` Christophe Lyon
2020-02-10 13:53 ` Jason Merrill
2020-02-10 14:39 ` Christophe Lyon
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).