Hey all,
I've been working on a concept extension that permits type aliases
inside the requires-seq.
The grammar addition is fairly simple.
```
requirement-seq
requirement
alias-declaration
requirement-seq requirement
```
Semantically, this change forces a requirement-body to open a new
scope to house the alias.
I've managed to get it working for variable concepts, but not function concepts.
It looks like type aliases for some concepts are tricking the compiler
into thinking that there are multiple statements.
For example:
```cpp
template
concept bool Foo =
requires(T a) {
using type = T;
using value_type = typename std::vector::value_type;
{a + a} -> value_type;
{a - a} -> type;
{a + a} -> typename std::vector::value_type;
{a - a} -> T;
};
```
works, but
```cpp
template
concept bool Foo() {
requires(T a) {
using type = T;
using value_type = typename std::vector::value_type;
{a + a} -> value_type;
{a - a} -> type;
{a + a} -> typename std::vector::value_type;
{a - a} -> T;
};
}
```
fails with
```
test.cpp: In function 'concept bool Foo()':
test.cpp:4:14: error: definition of concept 'concept bool Foo()' has
multiple statements
concept bool Foo() {
^~~
test.cpp: In function 'int main()':
test.cpp:17:10: error: deduced initializer does not satisfy
placeholder constraints
Foo i = 0;
^
test.cpp:17:10: note: in the expansion of concept '(Foo)()'
template concept bool Foo() [with T = int]
```
After some inspection, I've deduced that the issue is flagged in
constraint.cc:2527, where a DECL_EXPR is identified, instead of a
RETURN_EXPR.
I'm wondering if it's trivially possible to ignore these declarations?
E.g. a loop that somewhat resembles:
```cpp
while (body != TREE_NULL && TREE_CODE(STATEMENT_LIST_HEAD(body)) ==
DECL_EXPR && is also an alias declaration)
body = STATEMENT_LIST_TAIL(body);
if (body != TREE_NULL)
error...
// else cleared of all charges
```
Cheers,
Chris