1 // P2173R1 - Attributes on Lambda-Expressions
2 // { dg-do compile { target c++11 } }
7 auto a = [][[noreturn]] () {}; // { dg-warning "'noreturn' function does return" }
10 auto b = [][[noreturn]] {}; // { dg-warning "'noreturn' function does return" }
13 auto c = [] [[ deprecated ]] () {}; // { dg-bogus "is deprecated" }
14 c (); // { dg-warning "'foo\\\(bool, bool\\\)::<lambda\\\(\\\)>' is deprecated" }
15 auto d = [][[deprecated]] {}; // { dg-bogus "is deprecated" }
16 d (); // { dg-warning "'foo\\\(bool, bool\\\)::<lambda\\\(\\\)>' is deprecated" }
17 #if __cpp_generic_lambdas >= 201304
18 auto e = [] [[deprecated]] (auto x) {}; // { dg-bogus "is deprecated" }
19 e (0.0); // { dg-warning "'foo\\\(bool, bool\\\)::<lambda\\\(auto:1\\\)>\[^\n\r]*' is deprecated" "" { target c++14 } }
21 #if __cpp_generic_lambdas >= 201707
22 auto f = [] <typename T> [[deprecated]] (T) {}; // { dg-bogus "is deprecated" }
23 f (1); // { dg-warning "'foo\\\(bool, bool\\\)::<lambda\\\(T\\\)>\[^\n\r]*' is deprecated" "" { target c++20 } }
25 auto g = [][[nodiscard]](int) { return 1; };
26 g (1); // { dg-warning "ignoring return value of 'foo\\\(bool, bool\\\)::<lambda\\\(int\\\)>', declared with attribute 'nodiscard'" }
27 auto h = [] [[nodiscard]] { return 0; };
28 h (); // { dg-warning "ignoring return value of 'foo\\\(bool, bool\\\)::<lambda\\\(\\\)>', declared with attribute 'nodiscard'" }
29 auto i = [] [[ gnu::unavailable ]] () {};
30 auto j = [][[gnu::unavailable]] {};
31 #if __cpp_generic_lambdas >= 201304
32 auto k = [] [[gnu::unavailable]] (auto x) {}; // { dg-bogus "is unavailable" }
34 #if __cpp_generic_lambdas >= 201707
35 auto l = [] <typename T> [[gnu::unavailable]] (T) {}; // { dg-bogus "is unavailable" }