xref: /aosp_15_r20/external/clang/test/Parser/cxx1z-constexpr-lambdas.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++1z %s -verify
2*67e74705SXin Li // RUN: %clang_cc1 -std=c++14 %s -verify
3*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 %s -verify
4*67e74705SXin Li 
5*67e74705SXin Li 
6*67e74705SXin Li auto XL0 = [] constexpr { }; //expected-error{{requires '()'}} expected-error{{expected body}}
7*67e74705SXin Li auto XL1 = [] () mutable
8*67e74705SXin Li                  mutable     //expected-error{{cannot appear multiple times}}
__anonbb5ceda90102() 9*67e74705SXin Li                  mutable { }; //expected-error{{cannot appear multiple times}}
10*67e74705SXin Li 
11*67e74705SXin Li #if __cplusplus > 201402L
__anonbb5ceda90202() 12*67e74705SXin Li auto XL2 = [] () constexpr mutable constexpr { }; //expected-error{{cannot appear multiple times}}
__anonbb5ceda90302() 13*67e74705SXin Li auto L = []() mutable constexpr { };
__anonbb5ceda90402() 14*67e74705SXin Li auto L2 = []() constexpr { };
__anonbb5ceda90502() 15*67e74705SXin Li auto L4 = []() constexpr mutable { };
16*67e74705SXin Li auto XL16 = [] () constexpr
17*67e74705SXin Li                   mutable
18*67e74705SXin Li                   constexpr   //expected-error{{cannot appear multiple times}}
19*67e74705SXin Li                   mutable     //expected-error{{cannot appear multiple times}}
20*67e74705SXin Li                   mutable     //expected-error{{cannot appear multiple times}}
21*67e74705SXin Li                   constexpr   //expected-error{{cannot appear multiple times}}
22*67e74705SXin Li                   constexpr   //expected-error{{cannot appear multiple times}}
__anonbb5ceda90602() 23*67e74705SXin Li                   { };
24*67e74705SXin Li 
25*67e74705SXin Li #else
__anonbb5ceda90702() 26*67e74705SXin Li auto L = []() mutable constexpr {return 0; }; //expected-warning{{is a C++1z extension}}
__anonbb5ceda90802() 27*67e74705SXin Li auto L2 = []() constexpr { return 0;};//expected-warning{{is a C++1z extension}}
__anonbb5ceda90902() 28*67e74705SXin Li auto L4 = []() constexpr mutable { return 0; }; //expected-warning{{is a C++1z extension}}
29*67e74705SXin Li #endif
30*67e74705SXin Li 
31*67e74705SXin Li 
32