| 1 |
// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -Wno-vla-cxx-extension -verify |
| 2 |
#include "Inputs/std-coroutine.h" |
| 3 |
|
| 4 |
struct promise; |
| 5 |
|
| 6 |
struct coroutine : std::coroutine_handle<promise> { |
| 7 |
using promise_type = ::promise; |
| 8 |
}; |
| 9 |
|
| 10 |
struct promise |
| 11 |
{ |
| 12 |
coroutine get_return_object(); |
| 13 |
std::suspend_always initial_suspend() noexcept; |
| 14 |
std::suspend_always final_suspend() noexcept; |
| 15 |
void return_void(); |
| 16 |
void unhandled_exception(); |
| 17 |
}; |
| 18 |
|
| 19 |
// Test that we won't report the error incorrectly. |
| 20 |
void bar(int n) { |
| 21 |
int array[n]; |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
coroutine foo(int n) { |
| 26 |
int array[n]; // expected-error {{variable length arrays in a coroutine are not supported}} |
| 27 |
co_return; |
| 28 |
} |
| 29 |
|
| 30 |
void lambda() { |
| 31 |
[](int n) -> coroutine { |
| 32 |
int array[n]; // expected-error {{variable length arrays in a coroutine are not supported}} |
| 33 |
co_return; |
| 34 |
}(10); |
| 35 |
} |