1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
3 // RUN:    -fsyntax-only -ast-dump | FileCheck %s
4 //
5 // Test with serialization:
6 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -std=c++14 -fcoroutines-ts -emit-pch -o %t %s
7 // RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin9 -std=c++14 -fcoroutines-ts -include-pch %t \
8 // RUN: -ast-dump-all /dev/null \
9 // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
10 // RUN: | FileCheck %s
11 
12 #include "Inputs/std-coroutine.h"
13 
14 using namespace std::experimental;
15 
16 struct A {
17   bool await_ready();
18   void await_resume();
19   template <typename F>
20   void await_suspend(F);
21 };
22 
23 struct coro_t {
24   struct promise_type {
25     coro_t get_return_object();
26     suspend_never initial_suspend();
27     suspend_never final_suspend() noexcept;
28     void return_void();
29     static void unhandled_exception();
30   };
31 };
32 
33 // {{0x[0-9a-fA-F]+}} <line:[[@LINE+1]]:1, col:36>
34 // CHECK-LABEL: FunctionDecl {{.*}} f 'coro_t (int)'
f(int n)35 coro_t f(int n) {
36   A a{};
37   // CHECK: CoawaitExpr {{0x[0-9a-fA-F]+}} <col:3, col:12>
38   // CHECK-NEXT: DeclRefExpr {{0x[0-9a-fA-F]+}} <col:12>
39   // CHECK-NEXT: CXXMemberCallExpr {{0x[0-9a-fA-F]+}} <col:12>
40   // CHECK-NEXT: MemberExpr {{0x[0-9a-fA-F]+}} <col:12>
41   co_await a;
42 }
43