testsuite: 32 bit AIX 2 byte wchar
[official-gcc.git] / gcc / testsuite / g++.dg / cpp23 / lambda-attr1.C
bloba653c732fca44972e9a48d8d5bee0c0d1d2061d7
1 // P2173R1 - Attributes on Lambda-Expressions
2 // { dg-do compile { target c++11 } }
4 void
5 foo (bool x, bool y)
7   auto a = [][[noreturn]] () {};        // { dg-warning "'noreturn' function does return" }
8   if (x)
9     a ();
10   auto b = [][[noreturn]] {};           // { dg-warning "'noreturn' function does return" }
11   if (y)
12     b ();
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 } }
20 #endif
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 } }
24 #endif
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" }
33 #endif
34 #if __cpp_generic_lambdas >= 201707
35   auto l = [] <typename T> [[gnu::unavailable]] (T) {}; // { dg-bogus "is unavailable" }
36 #endif