xref: /llvm-project/clang/test/SemaCXX/warn-unused-parameters-coroutine.cpp (revision 858b56e4962749013ded409ff43370b542c8b6cb)
1 // RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++20 %s
2 
3 #include "Inputs/std-coroutine.h"
4 
5 struct awaitable {
6   bool await_ready() noexcept;
7   void await_resume() noexcept;
8   void await_suspend(std::coroutine_handle<>) noexcept;
9 };
10 
11 struct task : awaitable {
12   struct promise_type {
13     task get_return_object() noexcept;
14     awaitable initial_suspend() noexcept;
15     awaitable final_suspend() noexcept;
16     void unhandled_exception() noexcept;
17     void return_void() noexcept;
18   };
19 };
20 
foo(int a)21 task foo(int a) { // expected-warning{{unused parameter 'a'}}
22   co_return;
23 }
24 
bar(int a,int b)25 task bar(int a, int b) { // expected-warning{{unused parameter 'b'}}
26   a = a + 1;
27   co_return;
28 }
29 
create_closure()30 void create_closure() {
31   auto closure = [](int c) -> task { // expected-warning{{unused parameter 'c'}}
32     co_return;
33   };
34 }
35