c++: requires-expression and tentative parse [PR94480]
The problem here was that cp_parser_requires_expression committing to a tentative parse confused cp_parser_decltype_expr, which needs to still be tentative. The only reason to commit here is to get syntax errors within the requires-expression, which we can still do when the commit is firewalled from the enclosing context. gcc/cp/ChangeLog 2020-04-07 Jason Merrill <jason@redhat.com> PR c++/94480 * parser.c (cp_parser_requires_expression): Use tentative_firewall.
This commit is contained in:
parent
f1a6150ecb
commit
845d451e1f
|
@ -1,5 +1,8 @@
|
|||
2020-04-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/94480
|
||||
* parser.c (cp_parser_requires_expression): Use tentative_firewall.
|
||||
|
||||
PR c++/94481
|
||||
* parser.c (cp_parser_placeholder_type_specifier): Use
|
||||
matching_parens.
|
||||
|
|
|
@ -27740,6 +27740,9 @@ cp_parser_requires_expression (cp_parser *parser)
|
|||
gcc_assert (cp_lexer_next_token_is_keyword (parser->lexer, RID_REQUIRES));
|
||||
location_t loc = cp_lexer_consume_token (parser->lexer)->location;
|
||||
|
||||
/* Avoid committing to outer tentative parse. */
|
||||
tentative_firewall firewall (parser);
|
||||
|
||||
/* This is definitely a requires-expression. */
|
||||
cp_parser_commit_to_tentative_parse (parser);
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// PR c++/94480
|
||||
// { dg-do compile { target c++2a } }
|
||||
|
||||
template<typename T, typename U>
|
||||
constexpr bool is_same_v = __is_same (T, U);
|
||||
|
||||
static_assert(is_same_v<bool, decltype(requires { requires false; })>);
|
Loading…
Reference in New Issue