1 // RUN: %clang_cc1 -std=c++1y -verify -fblocks -emit-llvm-only %s
2 // RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fblocks -emit-llvm-only -Wno-deprecated-this-capture %s
3 // RUN: %clang_cc1 -std=c++1y -verify -fblocks -emit-llvm-only -triple i386-windows-pc %s
4 // RUN: %clang_cc1 -std=c++2a -verify -verify=expected-cxx2a -fblocks -emit-llvm-only -triple i386-windows-pc -Wno-deprecated-this-capture %s
5 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
6 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS
7 // DONTRUNYET: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
9 constexpr int ODRUSE_SZ
= sizeof(char);
11 template<class T
, int N
>
12 void f(T
, const int (&)[N
]) { }
15 void f(const T
&, const int (&)[ODRUSE_SZ
]) { }
17 #define DEFINE_SELECTOR(x) \
18 int selector_ ## x[sizeof(x) == ODRUSE_SZ ? ODRUSE_SZ : ODRUSE_SZ + 5]
20 #define F_CALL(x, a) f(x, selector_ ## a)
22 // This is a risky assumption, because if an empty class gets captured by value
23 // the lambda's size will still be '1'
24 #define ASSERT_NO_CAPTURES(L) static_assert(sizeof(L) == 1, "size of closure with no captures must be 1")
25 #define ASSERT_CLOSURE_SIZE_EXACT(L, N) static_assert(sizeof(L) == (N), "size of closure must be " #N)
26 #define ASSERT_CLOSURE_SIZE(L, N) static_assert(sizeof(L) >= (N), "size of closure must be >=" #N)
36 namespace test_transformations_in_templates
{
37 template<class T
> void foo(T t
) {
38 auto L
= [](auto a
) { return a
; };
40 template<class T
> void foo2(T t
) {
41 auto L
= [](auto a
) -> void {
42 auto M
= [](char b
) -> void {
43 auto N
= [](auto c
) -> void {
44 int selector
[sizeof(c
) == 1 ?
45 (sizeof(b
) == 1 ? 1 : 2)
62 namespace test_return_type_deduction
{
66 auto L
= [](auto a
, auto b
) {
67 if ( a
> b
) return a
;
72 auto L2
= [](auto a
, int i
) {
78 int a
; //expected-note{{declared here}}
79 auto B
= []() { return ^{ return a
; }; }; //expected-error{{cannot be implicitly capture}}\
80 //expected-note{{begins here}}\
81 //expected-note 2 {{capture 'a' by}}\
82 //expected-note 2 {{default capture by}}
83 //[](){ return ({int b = 5; return 'c'; 'x';}); };
85 //auto X = ^{ return a; };
87 //auto Y = []() -> auto { return 3; return 'c'; };
93 namespace test_no_capture
{
95 const int x
= 10; //expected-note{{declared here}}
97 // should not capture 'x' - variable undergoes lvalue-to-rvalue
98 auto L
= [=](auto a
) {
102 ASSERT_NO_CAPTURES(L
);
105 // should not capture 'x' - even though certain instantiations require
106 auto L
= [](auto a
) { //expected-note{{begins here}} expected-note 2 {{capture 'x' by}} expected-note 2 {{default capture by}}
108 F_CALL(x
, a
); //expected-error{{'x' cannot be implicitly captured}}
110 ASSERT_NO_CAPTURES(L
);
111 L('s'); //expected-note{{in instantiation of}}
114 // Does not capture because no default capture in inner most lambda 'b'
115 auto L
= [=](auto a
) {
124 ASSERT_NO_CAPTURES(L
);
129 namespace test_capture_of_potentially_evaluated_expression
{
133 auto L
= [=](auto a
) {
137 static_assert(sizeof(L
) == 4, "Must be captured");
140 int j
= 0; //expected-note{{declared}}
141 auto L
= [](auto a
) { //expected-note{{begins here}} expected-note 2 {{capture 'j' by}} expected-note 2 {{default capture by}}
142 return j
+ 1; //expected-error{{cannot be implicitly captured}}
147 auto L
= [](auto a
) {
162 { // if the nested capture does not implicitly or explicitly allow any captures
163 // nothing should capture - and instantiations will create errors if needed.
165 auto L
= [=](auto a
) { // <-- #A
167 return [](auto b
) { // <-- #B
174 ASSERT_NO_CAPTURES(L
);
176 ASSERT_NO_CAPTURES(M_int
);
178 { // Permutations of this example must be thoroughly tested!
181 auto L
= [=](auto a
) {
183 return [&,a
](auto b
) {
184 // expected-warning@-1 {{address of stack memory associated with local variable 'z' returned}}
185 // expected-note@#call {{in instantiation of}}
188 int d
[sizeof(a
) == sizeof(c
) || sizeof(c
) == sizeof(b
) ? 2 : 1];
191 f(z
, d
); // expected-note {{implicitly captured by reference due to use here}}
198 auto M
= L(3)(3.5); // #call
202 namespace Test_no_capture_of_clearly_no_odr_use
{
205 auto L
= [=](auto a
) {
215 ASSERT_NO_CAPTURES(L
);
216 ASSERT_NO_CAPTURES(N
);
222 namespace Test_capture_of_odr_use_var
{
225 auto L
= [=](auto a
) {
236 auto N_int_int
= M_int(2);
237 ASSERT_CLOSURE_SIZE_EXACT(L
, sizeof(x
));
238 // M_int captures both a & x
239 ASSERT_CLOSURE_SIZE_EXACT(M_int
, sizeof(x
) + sizeof(int));
240 // N_int_int captures both a & x
241 ASSERT_CLOSURE_SIZE_EXACT(N_int_int
, sizeof(x
) + sizeof(int));
242 auto M_double
= L(3.14);
243 ASSERT_CLOSURE_SIZE(M_double
, sizeof(x
) + sizeof(double));
251 namespace more_nested_captures_1
{
252 template<class T
> struct Y
{
253 static void f(int, double, ...) { }
255 static void f(const int&, R
, ...) { }
258 const int x
= 10; //expected-note{{declared here}}
259 auto L
= [](auto a
) {
262 f(x
, c
, b
, a
); //expected-error{{reference to local variable 'x'}}
270 N(5); //expected-note{{in instantiation of}}
274 int run
= (yi
.foo(3.14), 0); //expected-note{{in instantiation of}}
278 namespace more_nested_captures_1_1
{
279 template<class T
> struct Y
{
280 static void f(int, double, ...) { }
282 static void f(const int&, R
, ...) { }
285 const int x
= 10; //expected-note{{declared here}}
286 auto L
= [](auto a
) {
289 f(x
, c
, b
, a
); //expected-error{{reference to local variable 'x'}}
297 N(5); //expected-note{{in instantiation of}}
301 int run
= (yi
.foo(3.14), 0); //expected-note{{in instantiation of}}
303 namespace more_nested_captures_1_2
{
304 template<class T
> struct Y
{
305 static void f(int, double, ...) { }
307 static void f(const int&, R
, ...) { }
311 auto L
= [=](auto a
) {
326 int run
= (yi
.foo(3.14), 0);
329 namespace more_nested_captures_1_3
{
330 template<class T
> struct Y
{
331 static void f(int, double, ...) { }
333 static void f(const int&, R
, ...) { }
336 const int x
= 10; //expected-note{{declared here}}
337 auto L
= [=](auto a
) {
341 f(x
, c
, b
); //expected-error{{reference to local variable 'x'}}
350 N(5); //expected-note{{in instantiation of}}
354 int run
= (yi
.foo(3.14), 0); //expected-note{{in instantiation of}}
358 namespace more_nested_captures_1_4
{
359 template<class T
> struct Y
{
360 static void f(int, double, ...) { }
362 static void f(const int&, R
, ...) { }
365 const int x
= 10; //expected-note{{declared here}}
366 auto L
= [=](auto a
) {
369 const int y
= 0; //expected-note{{declared here}}
370 return [](auto c
) { //expected-note 2{{lambda expression begins here}} expected-note 2 {{capture 'x' by}} expected-note 2 {{capture 'y' by}} expected-note 4 {{default capture by}}
371 f(x
, c
); //expected-error{{variable 'x'}}
372 f(y
, c
); //expected-error{{variable 'y'}}
378 auto N_char
= M('b');
380 auto N_double
= M(3.14);
382 N_char(3); //expected-note{{in instantiation of}}
386 int run
= (yi
.foo('a'), 0); //expected-note{{in instantiation of}}
390 namespace more_nested_captures_2
{
391 template<class T
> struct Y
{
392 static void f(int, double) { }
394 static void f(const int&, R
) { }
398 auto L
= [=](auto a
) {
413 int run
= (yi
.foo(3.14), 0);
417 namespace more_nested_captures_3
{
418 template<class T
> struct Y
{
419 static void f(int, double) { }
421 static void f(const int&, R
) { }
424 const int x
= 10; //expected-note{{declared here}}
425 auto L
= [](auto a
) {
428 f(x
, c
); //expected-error{{reference to local variable 'x'}}
435 N(3); //expected-note{{in instantiation of}}
440 int run
= (yi
.foo(3.14), 0); //expected-note{{in instantiation of}}
444 namespace more_nested_captures_4
{
445 template<class T
> struct Y
{
446 static void f(int, double) { }
448 static void f(const int&, R
) { }
451 const int x
= 10; //expected-note{{'x' declared here}}
452 auto L
= [](auto a
) {
455 f(x
, c
); //expected-error{{reference to local variable 'x'}}
462 N(3); //expected-note{{in instantiation of}}
467 int run
= (yi
.foo(3.14), 0); //expected-note{{in instantiation of}}
471 namespace more_nested_captures_5
{
472 template<class T
> struct Y
{
473 static void f(int, double) { }
475 static void f(const int&, R
) { }
479 auto L
= [=](auto a
) {
494 int run
= (yi
.foo(3.14), 0);
498 namespace lambdas_in_NSDMIs
{
502 T t2
= ([](auto a
) { return [](auto b
) { return b
; };})(t
)(t
);
503 T t3
= ([](auto a
) { return a
; })(t
);
508 namespace test_nested_decltypes_in_trailing_return_types
{
510 auto L
= [](auto a
) {
511 return [](auto b
, decltype(a
) b2
) -> decltype(a
) {
512 return decltype(a
){};
521 namespace more_this_capture_1
{
524 static void f(double) { }
527 auto L
= [=](auto a
) {
534 auto L
= [](auto a
) { // expected-note {{explicitly capture 'this'}}
535 f(a
); //expected-error{{this}}
538 L(2); //expected-note{{in instantiation}}
543 auto L
= [=](auto a
) {
559 namespace more_this_capture_1_1
{
562 static void f(double) { }
565 auto L
= [=](auto a
) {
566 return [](int i
) { // expected-note {{explicitly capture 'this'}} expected-note {{while substituting into a lambda}}
567 return [=](auto b
) { // expected-note {{while substituting into a lambda}}
568 f(decltype(a
){}); //expected-error{{this}}
576 L(3); // expected-note{{instantiation}}
583 namespace more_this_capture_1_1_1
{
586 static void f(double) { }
589 auto L
= [=](auto a
) {
590 return [](auto b
) { // expected-note {{explicitly capture 'this'}} expected-note {{while substituting into a lambda}}
591 return [=](int i
) { // expected-note {{while substituting into a lambda}}
593 f(decltype(a
){}); //expected-error{{this}}
597 auto M
= L(0.0); // OK
598 auto N
= M(3.3); //OK
599 auto M_int
= L(0); //expected-note{{instantiation}}
607 namespace more_this_capture_1_1_1_1
{
610 static void f(double) { }
613 auto L
= [=](auto a
) {
614 return [](auto b
) { // expected-note {{explicitly capture 'this'}}
615 return [=](int i
) { // expected-note {{while substituting into a lambda}}
616 f(b
); //expected-error{{this}}
621 auto M_double
= L(0.0); // OK
622 auto N
= M_double(3); //expected-note{{instantiation}}
630 namespace more_this_capture_2
{
633 static void f(double) { }
636 auto L
= [=](auto a
) {
638 return [=](auto b
) { // expected-cxx2a-note {{explicitly capture 'this'}}
639 f(b
); //expected-error{{'this' cannot}}
646 N(5); // NOT OK expected-note{{in instantiation of}}
652 namespace diagnose_errors_early_in_generic_lambdas
{
657 { // This variable is used and must be caught early, do not need instantiation
658 const int x
= 0; //expected-note{{declared}}
659 auto L
= [](auto a
) { //expected-note{{begins}} expected-note 2 {{capture 'x' by}} expected-note 2 {{default capture by}}
660 const int &r
= x
; //expected-error{{variable}}
663 { // This variable is not used
665 auto L
= [](auto a
) {
671 const int x
= 0; //expected-note{{declared}}
672 auto L
= [=](auto a
) { // <-- #A
674 return [](auto b
) { //expected-note{{begins}} expected-note 2 {{capture 'x' by}} expected-note 2 {{default capture by}}
679 // This use will always be an error regardless of instantiation
680 // so diagnose this early.
681 const int &r
= x
; //expected-error{{variable}}
692 namespace generic_nongenerics_interleaved_1
{
716 // FIXME: why are there 2 error messages here?
718 auto L
= [](auto a
) { //expected-note {{declared here}}
719 int y
= 10; //expected-note {{declared here}}
720 return [](int b
) { //expected-note 2{{expression begins here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{capture 'y' by}} expected-note 4 {{default capture by}}
721 return [=] (auto c
) {
722 return a
+ y
; //expected-error 2{{cannot be implicitly captured}}
729 auto L
= [](auto a
) {
732 return [=] (auto c
) {
743 namespace dont_capture_refs_if_initialized_with_constant_expressions
{
746 // This is surprisingly not odr-used within the lambda!
750 return [](auto a
) { return ref_j
; }; // ok
755 // This is surprisingly not odr-used within the lambda!
759 return [](auto a
) { return ref_j
; }; // ok
765 auto L_char
= L('a');
766 auto L1
= foo2(3.14);
768 auto L1_char
= L1('a');
772 } // dont_capture_refs_if_initialized_with_constant_expressions
774 namespace test_conversion_to_fptr
{
776 template<class T
> struct X
{
778 T (*fp
)(T
) = [](auto a
) { return a
; };
785 void fooT(T t
, T (*fp
)(T
) = [](auto a
) { return a
; }) {
791 auto L
= [](auto a
) { return a
; };
795 char (*fc
)(char) = L
;
798 double (*fd
)(double) = L
;
804 auto L
= [](auto a
) ->int { return a
; }; //expected-note 2{{candidate template ignored}}
806 char (*fc
)(char) = L
; //expected-error{{no viable conversion}}
807 double (*fd
)(double) = L
; //expected-error{{no viable conversion}}
811 auto L
= [=](auto b
, char c
= 'x') {
813 return [](auto a
) ->decltype(a
) { return a
; };
815 int (*fp
)(int) = L(8);
818 char (*fc
)(char) = L('a');
821 double (*fd
)(double) = L(3.14);
827 auto L
= [=](auto b
) {
828 return [](auto a
) ->decltype(b
)* { return (decltype(b
)*)0; };
830 int* (*fp
)(int) = L(8);
833 char* (*fc
)(char) = L('a');
836 double* (*fd
)(double) = L(3.14);
841 auto L
= [=](auto b
) {
842 return [](auto a
) ->decltype(b
)* { return (decltype(b
)*)0; }; //expected-note{{candidate template ignored}}
844 char* (*fp
)(int) = L('8');
846 char* (*fc
)(char) = L('a');
848 double* (*fi
)(int) = L(3.14);
850 int* (*fi2
)(int) = L(3.14); //expected-error{{no viable conversion}}
854 auto L
= [=](auto b
) {
857 return [](auto d
) ->decltype(a
+ b
+ c
+ d
) { return d
; };
861 int (*fp
)(int) = L('8')(3)(short{});
862 double (*fs
)(char) = L(3.14)(short{})('4');
876 namespace this_capture
{
877 void f(char, int) { }
879 void f(T
, const int&) { }
884 auto L
= [=](auto a
) {
898 int run
= (X
{}.foo(), 0);
900 namespace this_capture_unresolvable
{
903 static void f(double) { }
906 auto lam
= [=](auto a
) { f(a
); }; // captures 'this'
912 auto lam
= [](auto a
) { f(a
); }; // expected-error{{'this'}} expected-note {{explicitly capture 'this'}}
913 lam(0); // expected-note{{in instantiation of}}
917 double (*fd
)(double) = [](auto a
) { f(a
); return a
; };
925 namespace check_nsdmi_and_this_capture_of_member_functions
{
927 struct FunctorDouble
{
928 template<class T
> FunctorDouble(T t
) { t(2.14); };
931 template<class T
> FunctorInt(T t
) { t(2); }; //expected-note{{in instantiation of}}
934 template<class T
> struct YUnresolvable
{
936 static void f(double) { }
938 T t
= [](auto a
) { f(a
); return a
; };
939 T t2
= [=](auto b
) { f(b
); return b
; };
942 template<class T
> struct YUnresolvable2
{
944 static void f(double) { }
946 T t
= [](auto a
) { f(a
); return a
; }; //expected-error{{'this'}} \
947 //expected-note{{in instantiation of}}\
948 //expected-note {{explicitly capture 'this'}}
949 T t2
= [=](auto b
) { f(b
); return b
; };
953 YUnresolvable
<FunctorDouble
> yud
;
954 // This will cause an error since it call's with an int and calls a member function.
955 YUnresolvable2
<FunctorInt
> yui
;
958 template<class T
> struct YOnlyStatic
{
959 static void f(double) { }
961 T t
= [](auto a
) { f(a
); return a
; };
963 YOnlyStatic
<FunctorDouble
> yos
;
964 template<class T
> struct YOnlyNonStatic
{
967 T t
= [](auto a
) { f(a
); return a
; }; //expected-error{{'this'}} expected-note {{explicitly capture 'this'}}
974 namespace check_nsdmi_and_this_capture_of_data_members
{
976 struct FunctorDouble
{
977 template<class T
> FunctorDouble(T t
) { t(2.14); };
980 template<class T
> FunctorInt(T t
) { t(2); };
983 template<class T
> struct YThisCapture
{
986 T t
= [](auto a
) { return x
; }; //expected-error{{'this'}} expected-note {{explicitly capture 'this'}}
987 T t2
= [](auto b
) { return d
; };
988 T t3
= [this](auto a
) {
998 T t5
= [](auto a
) { // expected-note {{explicitly capture 'this'}}
1000 return x
; //expected-error{{'this'}}
1005 template<class T
> double YThisCapture
<T
>::d
= 3.14;
1011 #ifdef DELAYED_TEMPLATE_PARSING
1012 template<class T
> void foo_no_error(T t
) {
1016 template<class T
> void foo(T t
) { //expected-note 2{{declared here}}
1017 auto L
= []() //expected-note 2{{begins here}}
1018 { return t
; }; //expected-error 2{{cannot be implicitly captured}}
1020 template void foo(int); //expected-note{{in instantiation of}}
1024 template<class T
> void foo(T t
) { //expected-note{{declared here}}
1025 auto L
= []() //expected-note{{begins here}} expected-note 2 {{capture 't' by}} expected-note 2 {{default capture by}}
1026 { return t
; }; //expected-error{{cannot be implicitly captured}}
1032 namespace no_this_capture_for_static
{
1035 static void f(double) { }
1038 auto lam
= [=](auto a
) { f(a
); };
1040 ASSERT_NO_CAPTURES(lam
);
1048 namespace this_capture_for_non_static
{
1054 auto L
= [=](auto a
) { f(a
); };
1056 auto L2
= [](auto a
) { f(a
); }; //expected-error {{cannot be implicitly captured}} expected-note {{explicitly capture 'this'}}
1064 namespace this_captures_with_num_args_disambiguation
{
1068 static void f(double, int i
) { }
1070 auto lam
= [](auto a
) { f(a
, a
); };
1078 namespace enclosing_function_is_template_this_capture
{
1079 // Only error if the instantiation tries to use the member function.
1082 static void f(double) { }
1085 auto L
= [](auto a
) { f(a
); }; //expected-error{{'this'}} expected-note {{explicitly capture 'this'}}
1086 L(t
); // expected-note{{in instantiation of}}
1091 int run
= X
{}.g(0.0); // OK.
1092 int run2
= X
{}.g(0); // expected-note{{in instantiation of}}
1097 namespace enclosing_function_is_template_this_capture_2
{
1098 // This should error, even if not instantiated, since
1099 // this would need to be captured.
1104 auto L
= [](auto a
) { f(a
); }; //expected-error{{'this'}} expected-note {{explicitly capture 'this'}}
1113 namespace enclosing_function_is_template_this_capture_3
{
1114 // This should not error, this does not need to be captured.
1116 static void f(int) { }
1119 auto L
= [](auto a
) { f(a
); };
1125 int run
= X
{}.g(0.0); // OK.
1126 int run2
= X
{}.g(0); // OK.
1130 namespace nested_this_capture_1
{
1133 static void f(double) { }
1136 auto L
= [=](auto a
) {
1138 return [=](auto b
) {
1155 namespace nested_this_capture_2
{
1158 static void f(double) { }
1161 auto L
= [=](auto a
) {
1163 return [=](auto b
) {
1180 namespace nested_this_capture_3_1
{
1183 void f(int, T t
) { }
1185 static void f(double, T t
) { }
1188 auto L
= [=](auto a
) {
1189 return [&](auto c
) {
1190 return [=](auto b
) {
1208 namespace nested_this_capture_3_2
{
1211 static void f(double) { }
1214 auto L
= [=](auto a
) {
1216 return [=](auto b
) { // expected-cxx2a-note {{explicitly capture 'this'}}
1217 f(b
); //expected-error {{'this' cannot}}
1224 N(5); //expected-note {{in instantiation of}}
1234 namespace nested_this_capture_4
{
1237 static void f(double) { }
1240 auto L
= [](auto a
) {
1241 return [=](auto i
) {
1242 return [=](auto b
) { // expected-cxx2a-note {{explicitly capture 'this'}}
1243 f(b
); //expected-error {{'this' cannot}}
1250 N(5); //expected-note {{in instantiation of}}
1259 namespace capture_enclosing_function_parameters
{
1262 inline auto foo(int x
) {
1264 auto lambda
= [=](auto z
) { return x
+ z
; };
1276 inline auto foo3(int x
) {
1278 auto L
= [=](auto a
) {
1280 return [=](auto b
) mutable {
1282 return [&, n
](auto c
) mutable {
1288 auto M
= L("foo-abc");
1289 auto N
= M("foo-def");
1290 auto O
= N("foo-ghi");
1297 auto M3
= L3("L3-1");
1298 auto N3
= M3("M3-1");
1299 auto O3
= N3("N3-1");
1307 namespace capture_arrays
{
1309 inline int sum_array(int n
) {
1310 int array2
[5] = { 1, 2, 3, 4, 5};
1312 auto L
= [=](auto N
) -> int {
1314 int array
[5] = { 1, 2, 3, 4, 5 };
1324 namespace capture_non_odr_used_variable_because_named_in_instantiation_dependent_expressions
{
1326 // even though 'x' is not odr-used, it should be captured.
1330 auto L
= [=](auto a
) {
1333 ASSERT_CLOSURE_SIZE_EXACT(L
, sizeof(x
));
1337 #ifdef MS_EXTENSIONS
1338 namespace explicit_spec
{
1339 template<class R
> struct X
{
1340 template<class T
> int foo(T t
) {
1341 auto L
= [](auto a
) { return a
; };
1346 template<> int foo
<char>(char c
) { //expected-warning{{explicit specialization}}
1348 auto LC
= [](auto a
) { return a
; };
1351 auto L
= [=](auto a
) {
1352 return [=](auto b
) {
1359 ASSERT_NO_CAPTURES(M
);
1365 int run_char
= X
<int>{}.foo('a');
1366 int run_int
= X
<double>{}.foo(4);
1368 #endif // MS_EXTENSIONS
1370 namespace nsdmi_capturing_this
{
1373 int n
= [this](auto) { return m
; }(20);
1379 T n
= [this](auto) { return m
; }(20);
1387 void PR33318(int i
) {
1388 [&](auto) { static_assert(&i
!= nullptr, ""); }(0); // expected-warning 2{{always true}} expected-note {{instantiation}}
1391 // Check to make sure that we don't capture when member-calls are made to members that are not of 'this' class.
1393 // https://bugs.llvm.org/show_bug.cgi?id=34266
1396 static void bar(int) { }
1397 static void bar(double) { }
1409 ASSERT_NO_CAPTURES(L
);
1421 static void bar(int) { }
1422 static void bar(double) { }
1429 auto L
= [=](auto a
) {
1434 ASSERT_NO_CAPTURES(L
);
1448 static void bar(double) { }
1455 auto L
= [=](auto a
) {
1457 T::bar(a
); // This call ignores the instance member function because the implicit object argument fails to convert.
1460 ASSERT_NO_CAPTURES(L
);
1476 static void bar(double) { }
1483 auto L
= [=](auto a
) {
1488 // just check to see if the size if >= 2 bytes (which should be the case if we capture anything)
1489 ASSERT_CLOSURE_SIZE(L
, 2);
1504 static void bar(double) { }
1511 auto L
= [&](auto a
) {
1517 ASSERT_NO_CAPTURES(L
);
1531 namespace capture_pack
{
1532 #if __cplusplus >= 201702L
1538 ((a
= b
), ...); // expected-warning 0-1{{extension}}
1540 return (a
+ ...); // expected-warning 0-1{{extension}}
1542 #if __cplusplus >= 201702L
1543 static_assert(v
== 123);