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.
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.
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);
--- /dev/null
+// 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; })>);