[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / addr-label-in-coroutines.cpp
blobe37ee641343788a171108dec4cad7ddaa76776d2
1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
3 #include "Inputs/std-coroutine.h"
5 struct resumable {
6 struct promise_type {
7 resumable get_return_object() { return {}; }
8 auto initial_suspend() { return std::suspend_always(); }
9 auto final_suspend() noexcept { return std::suspend_always(); }
10 void unhandled_exception() {}
11 void return_void(){};
15 resumable f1(int &out, int *inst) {
16 static void* dispatch_table[] = {&&inc, // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
17 &&suspend, // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
18 &&stop}; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
19 #define DISPATCH() goto *dispatch_table[*inst++]
20 inc:
21 out++;
22 DISPATCH();
24 suspend:
25 co_await std::suspend_always{};
26 DISPATCH();
28 stop:
29 co_return;
32 resumable f2(int &out, int *inst) {
33 void* dispatch_table[] = {nullptr, nullptr, nullptr};
34 dispatch_table[0] = &&inc; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
35 dispatch_table[1] = &&suspend; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
36 dispatch_table[2] = &&stop; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
37 #define DISPATCH() goto *dispatch_table[*inst++]
38 inc:
39 out++;
40 DISPATCH();
42 suspend:
43 co_await std::suspend_always{};
44 DISPATCH();
46 stop:
47 co_return;
50 resumable f3(int &out, int *inst) {
51 void* dispatch_table[] = {nullptr, nullptr, nullptr};
52 [&]() -> resumable {
53 dispatch_table[0] = &&inc; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
54 dispatch_table[1] = &&suspend; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
55 dispatch_table[2] = &&stop; // expected-error {{the GNU address of label extension is not allowed in coroutines.}}
56 #define DISPATCH() goto *dispatch_table[*inst++]
57 inc:
58 out++;
59 DISPATCH();
61 suspend:
62 co_await std::suspend_always{};
63 DISPATCH();
65 stop:
66 co_return;
67 }();
69 co_return;