File: cxx2b-lambdas.cpp

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,418,840 kB
  • sloc: cpp: 5,290,826; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,898; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,913; xml: 953; cs: 573; fortran: 539
file content (40 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// RUN: %clang_cc1 -std=c++2b %s -verify

auto LL0 = [] {};
auto LL1 = []() {};
auto LL2 = []() mutable {};
auto LL3 = []() constexpr {};

auto L0 = [] constexpr {};
auto L1 = [] mutable {};
auto L2 = [] noexcept {};
auto L3 = [] constexpr mutable {};
auto L4 = [] mutable constexpr {};
auto L5 = [] constexpr mutable noexcept {};
auto L6 = [s = 1] mutable {};
auto L7 = [s = 1] constexpr mutable noexcept {};
auto L8 = [] -> bool { return true; };
auto L9 = []<typename T> { return true; };
auto L10 = []<typename T> noexcept { return true; };
auto L11 = []<typename T> -> bool { return true; };
auto L12 = [] consteval {};
auto L13 = []() requires true {};
auto L14 = []<auto> requires true() requires true {};
auto L15 = []<auto> requires true noexcept {};
auto L16 = [] [[maybe_unused]]{};

auto XL0 = [] mutable constexpr mutable {};    // expected-error{{cannot appear multiple times}}
auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body of lambda expression}}
auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
                                               // expected-error{{function parameter cannot be constexpr}} \
                                               // expected-error{{C++ requires}} \
                                               // expected-error{{expected ')'}} \
                                               // expected-note{{to match this '('}} \
                                               // expected-error{{expected body}} \
                                               // expected-warning{{duplicate 'constexpr'}}

// http://llvm.org/PR49736
auto XL4 = [] requires true {}; // expected-error{{expected body}}
auto XL5 = []<auto> requires true requires true {}; // expected-error{{expected body}}
auto XL6 = []<auto> requires true noexcept requires true {}; // expected-error{{expected body}}