clang-concepts-monorepo
clang-concepts-monorepo copied to clipboard
Parsing: Retry as expression instead when reaching open-brace at block-scope
Given:
constexpr bool q = true;
constexpr auto x = [] { return 42; };
using FTy = decltype(x);
void g(bool);
void f() {
FTy (x)() &
requires(bool (q)) { g(q); };
}
The {
should trigger parsing of the statement as an expression-statement since, in this context, it can start neither a function-body nor an initializer.
Currently we get:
<source>:8:22: error: function definition is not allowed here
requires(bool (q)) { g(q); };
^
1 error generated.
Nice catch! Is this supposed to be well-formed though? Why would a requires-expression be allowed after that &?
Why would a requires-expression be allowed after that &?
The first part is a call that produces an int
; a requires-expression is just a bool
, and thus allowed there.
gotcha