1 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -emit-llvm-only %s
2 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
3 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fms-extensions %s -DMS_EXTENSIONS
4 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
5 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -triple i386-windows-pc -emit-llvm-only %s
6 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -triple i386-windows-pc -fdelayed-template-parsing %s -DDELAYED_TEMPLATE_PARSING
7 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -triple i386-windows-pc -fms-extensions %s -DMS_EXTENSIONS
8 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only -fblocks -triple i386-windows-pc -fdelayed-template-parsing -fms-extensions %s -DMS_EXTENSIONS -DDELAYED_TEMPLATE_PARSING
10 template<class F
, class ...Rest
> struct first_impl
{ typedef F type
; };
11 template<class ...Args
> using first
= typename first_impl
<Args
...>::type
;
13 namespace simple_explicit_capture
{
16 auto L
= [i
](auto a
) { return i
+ a
; };
21 namespace explicit_call
{
23 auto L
= [](auto a
) { return a
; };
25 L
.operator()<char>(3.14); //expected-warning{{implicit conversion}}
30 namespace test_conversion_to_fptr_2
{
32 template<class T
> struct X
{
34 T (*fp
)(T
) = [](auto a
) { return a
; };
41 void fooT(T t
, T (*fp
)(T
) = [](auto a
) { return a
; }) {
47 auto L
= [](auto a
) { return a
; };
54 double (*fd
)(double) = L
;
60 auto L
= [](auto a
) ->int { return a
; }; //expected-note 2{{candidate template ignored}}
62 char (*fc
)(char) = L
; //expected-error{{no viable conversion}}
63 double (*fd
)(double) = L
; //expected-error{{no viable conversion}}
67 auto L
= [=](auto b
, char c
= 'x') {
69 return [](auto a
) ->decltype(a
) { return a
; };
71 int (*fp
)(int) = L(8);
74 char (*fc
)(char) = L('a');
77 double (*fd
)(double) = L(3.14);
83 auto L
= [=](auto b
) {
84 return [](auto a
) ->decltype(b
)* { return (decltype(b
)*)0; };
86 int* (*fp
)(int) = L(8);
89 char* (*fc
)(char) = L('a');
92 double* (*fd
)(double) = L(3.14);
97 auto L
= [=](auto b
) {
98 return [](auto a
) ->decltype(b
)* { return (decltype(b
)*)0; }; //expected-note{{candidate template ignored}}
100 char* (*fp
)(int) = L('8');
102 char* (*fc
)(char) = L('a');
104 double* (*fi
)(int) = L(3.14);
106 int* (*fi2
)(int) = L(3.14); //expected-error{{no viable conversion}}
110 auto L
= [=](auto b
) {
113 return [](auto d
) ->decltype(a
+ b
+ c
+ d
) { return d
; };
117 int (*fp
)(int) = L('8')(3)(short{});
118 double (*fs
)(char) = L(3.14)(short{})('4');
132 namespace test_conversion_to_fptr
{
134 void f1(int (*)(int)) { }
135 void f2(char (*)(int)) { } // expected-note{{candidate}}
136 void g(int (*)(int)) { } // #1 expected-note{{candidate}}
137 void g(char (*)(char)) { } // #2 expected-note{{candidate}}
138 void h(int (*)(int)) { } // #3
139 void h(char (*)(int)) { } // #4
143 auto glambda
= [](auto a
) { return a
; };
146 f2(glambda
); // expected-error{{no matching function}}
147 g(glambda
); // expected-error{{call to 'g' is ambiguous}}
148 h(glambda
); // OK: calls #3 since it is convertible from ID
150 int& (*fpi
)(int*) = [](auto* a
) -> auto& { return *a
; }; // OK
155 auto L
= [](auto a
) { return a
; };
159 char (*fc
)(char) = L
;
162 double (*fd
)(double) = L
;
168 auto L
= [](auto a
) ->int { return a
; }; //expected-note 2{{candidate template ignored}}
170 char (*fc
)(char) = L
; //expected-error{{no viable conversion}}
171 double (*fd
)(double) = L
; //expected-error{{no viable conversion}}
174 int* (*fp
)(int*) = [](auto *a
) -> auto* { return a
; };
179 namespace more_converion_to_ptr_to_function_tests
{
184 int& (*fpi
)(int*) = [](auto* a
) -> auto& { return *a
; }; // OK
185 int (*fp2
)(int) = [](auto b
) -> int { return b
; };
186 int (*fp3
)(char) = [](auto c
) -> int { return c
; };
187 char (*fp4
)(int) = [](auto d
) { return d
; }; //expected-error{{no viable conversion}}\
188 //expected-note{{candidate function [with d:auto = int]}}
189 char (*fp5
)(char) = [](auto e
) -> int { return e
; }; //expected-error{{no viable conversion}}\
190 //expected-note{{candidate template ignored}}
199 template<class ... Ts
> void vfun(Ts
... ) { }
201 int variadic_test() {
203 int (*fp
)(int, char, double) = [](auto ... a
) -> int { vfun(a
...); return 4; };
206 int (*fp2
)(int, char, double) = [](auto ... a
) { vfun(a
...); return 4; };
213 namespace conversion_operator
{
215 auto L
= [](auto a
) -> int { return a
; }; // expected-error {{cannot initialize}}
217 int (&fp2
)(int) = [](auto a
) { return a
; }; // expected-error{{non-const lvalue}}
218 int (&&fp3
)(int) = [](auto a
) { return a
; };
219 // expected-error@-1 {{no viable conversion}}
220 // expected-note-re@-2 {{candidate template ignored: could not match 'auto (*)(type-parameter-0-0){{.*}}' against 'int (int)'}}
223 using G
= int(void*);
225 L
.operator G
*(); // expected-note-re {{instantiation of function template specialization '{{.*}}::operator()<void *>'}}
227 // Here, the conversion function is named 'operator auto (*)(int)', and
228 // there is no way to write that name in valid C++.
229 auto M
= [](auto a
) -> auto { return a
; };
230 M
.operator F
*(); // expected-error {{no member named 'operator int (*)(int)'}}
235 namespace return_type_deduction_ok
{
236 auto l
= [](auto a
) ->auto { return a
; }(2);
237 auto l2
= [](auto a
) ->decltype(auto) { return a
; }(2);
238 auto l3
= [](auto a
) { return a
; }(2);
242 namespace generic_lambda_as_default_argument_ok
{
243 void test(int i
= [](auto a
)->int { return a
; }(3)) {
247 namespace nested_non_capturing_lambda_tests
{
248 template<class ... Ts
> void print(Ts
...) { }
251 auto L
= [](auto a
) {
260 int i
= 10; //expected-note 3{{declared here}}
261 auto L
= [](auto a
) {
262 return [](auto b
) { //expected-note 3{{begins here}} expected-note 6 {{capture 'i' by}} expected-note 6 {{default capture by}} expected-note {{while substituting into a lambda}}
263 i
= b
; //expected-error 3{{cannot be implicitly captured}}
267 auto M
= L(3); //expected-note{{instantiation}}
268 M(4.15); //expected-note{{instantiation}}
272 auto L
= [](auto a
) {
280 auto L
= [](auto a
) {
281 print("a = ", a
, "\n");
282 return [](auto b
) ->decltype(a
) {
283 print("b = ", b
, "\n");
292 auto L
= [](auto a
) ->decltype(a
) {
293 print("a = ", a
, "\n");
294 return [](auto b
) ->decltype(a
) {
295 // expected-error@-1 {{no viable conversion}}
296 // expected-note-re@-2 {{candidate template ignored: could not match 'int (*)(type-parameter-0-0){{.*}}' against 'int'}}
297 print("b = ", b
, "\n");
301 auto M
= L(3); //expected-note{{in instantiation of}}
304 auto L
= [](auto a
) {
305 print("a = ", a
, "\n");
306 return [](auto ... b
) ->decltype(a
) {
307 print("b = ", b
..., "\n");
316 auto L
= [](auto a
) {
317 print("a = ", a
, "\n");
318 return [](auto ... b
) ->decltype(a
) {
319 print("b = ", b
..., "\n");
324 int (*fp
)(double, int, const char*) = M
;
329 auto L
= [](auto a
) {
330 print("a = ", a
, "\n");
332 return [](auto ... c
) ->decltype(b
) {
333 print("c = ", c
..., "\n");
342 N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
343 char (*np
)(const char*, int, const char*, double, const char*, int) = N
;
344 np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
349 auto L
= [](auto a
) {
350 print("a = ", a
, "\n");
351 return [](decltype(a
) b
) {
352 return [](auto ... c
) ->decltype(b
) {
353 print("c = ", c
..., "\n");
362 N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
363 char (*np
)(const char*, int, const char*, double, const char*, int) = N
;
364 np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
370 static void foo(double d
) { }
372 auto L
= [](auto a
) {
373 print("a = ", a
, "\n");
375 return [](decltype(a
) b
) {
377 foo(sizeof(a
) + sizeof(b
));
378 return [](auto ... c
) ->decltype(b
) {
379 print("c = ", c
..., "\n");
381 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
390 N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
391 char (*np
)(const char*, int, const char*, double, const char*, int) = N
;
392 np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
398 // Make sure we can escape the function
401 static void foo(double d
) { }
403 auto L
= [](auto a
) {
404 print("a = ", a
, "\n");
406 return [](decltype(a
) b
) {
408 foo(sizeof(a
) + sizeof(b
));
409 return [](auto ... c
) ->decltype(b
) {
410 print("c = ", c
..., "\n");
412 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
426 N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
427 char (*np
)(const char*, int, const char*, double, const char*, int) = N
;
428 np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
433 static void foo(double d
) { }
435 auto L
= [](auto a
) {
436 print("a = ", a
, "\n");
438 return [](decltype(a
) b
) {
440 foo(sizeof(a
) + sizeof(b
));
441 return [](auto ... c
) {
442 print("c = ", c
..., "\n");
444 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
445 return [](decltype(c
) ... d
) ->decltype(a
) { //expected-note{{candidate}}
446 print("d = ", d
..., "\n");
448 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
449 return decltype(a
){};
463 auto O
= N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
464 char (*np
)(const char*, int, const char*, double, const char*, int) = O
;
465 np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
466 int (*np2
)(const char*, int, const char*, double, const char*, int) = O
; // expected-error{{no viable conversion}}
471 namespace wrapped_within_templates
{
473 namespace explicit_return
{
474 template<class T
> int fooT(T t
) {
475 auto L
= [](auto a
) -> void {
476 auto M
= [](char b
) -> void {
477 auto N
= [](auto c
) -> void {
492 int run
= fooT('a') + fooT(3.14);
494 } // end explicit_return
496 namespace implicit_return_deduction
{
497 template<class T
> auto fooT(T t
) {
498 auto L
= [](auto a
) {
499 auto M
= [](char b
) {
500 auto N
= [](auto c
) {
515 int run
= fooT('a') + fooT(3.14);
517 template<class ... Ts
> void print(Ts
... ts
) { }
519 template<class ... Ts
> auto fooV(Ts
... ts
) {
520 auto L
= [](auto ... a
) {
521 auto M
= [](decltype(a
) ... b
) {
522 auto N
= [](auto c
) {
533 print("a = ", a
..., "\n");
536 print("ts = ", ts
..., "\n");
540 int run2
= fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{});
542 } //implicit_return_deduction
545 } //wrapped_within_templates
547 namespace at_ns_scope
{
548 void foo(double d
) { }
550 auto L
= [](auto a
) {
551 print("a = ", a
, "\n");
553 return [](decltype(a
) b
) {
555 foo(sizeof(a
) + sizeof(b
));
556 return [](auto ... c
) {
557 print("c = ", c
..., "\n");
559 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
560 return [](decltype(c
) ... d
) ->decltype(a
) { //expected-note{{candidate}}
561 print("d = ", d
..., "\n");
563 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
564 return decltype(a
){};
572 auto L_test
= L('4');
574 auto M_test
= M('a');
576 auto O
= N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
577 char (*np
)(const char*, int, const char*, double, const char*, int) = O
;
578 auto NP_result
= np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
579 int (*np2
)(const char*, int, const char*, double, const char*, int) = O
; // expected-error{{no viable conversion}}
585 namespace variadic_tests_1
{
586 template<class ... Ts
> void print(Ts
... ts
) { }
588 template<class F
, class ... Rest
> F
& FirstArg(F
& f
, Rest
...) { return f
; }
590 template<class ... Ts
> int fooV(Ts
... ts
) {
591 auto L
= [](auto ... a
) -> void {
592 auto M
= [](decltype(a
) ... b
) -> void {
593 auto N
= [](auto c
) -> void {
604 print("a = ", a
..., "\n");
607 print("ts = ", ts
..., "\n");
611 int run2
= fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{});
613 namespace more_variadic_1
{
615 template<class ... Ts
> int fooV(Ts
... ts
) {
616 auto L
= [](auto ... a
) {
617 auto M
= [](decltype(a
) ... b
) -> void {
618 auto N
= [](auto c
) -> void {
631 auto M
= L(L
, ts
...);
632 decltype(L(L
, ts
...)) (*fp
)(decltype(L
), decltype(ts
) ...) = L
;
633 void (*fp2
)(decltype(L
), decltype(ts
) ...) = L(L
, ts
...);
636 auto L
= [](auto ... a
) {
637 auto M
= [](decltype(a
) ... b
) {
638 auto N
= [](auto c
) -> void {
652 auto M
= L(L
, ts
...);
653 decltype(L(L
, ts
...)) (*fp
)(decltype(L
), decltype(ts
) ...) = L
;
655 decltype(L(L
, ts
...)(L
, ts
...)) (*fp2
)(decltype(L
), decltype(ts
) ...) = L(L
, ts
...);
657 void (*fp3
)(char) = fp2(L
, ts
...);
663 int run2
= fooV(3.14, " ", '4', 5) + fooV("BC", 3, 2.77, 'A', float{}, short{}, unsigned{});
666 } //end ns more_variadic_1
668 } // end ns variadic_tests_1
670 namespace at_ns_scope_within_class_member
{
672 static void foo(double d
) { }
674 auto L
= [](auto a
) {
675 print("a = ", a
, "\n");
677 return [](decltype(a
) b
) {
679 foo(sizeof(a
) + sizeof(b
));
680 return [](auto ... c
) {
681 print("c = ", c
..., "\n");
683 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
684 return [](decltype(c
) ... d
) ->decltype(a
) { //expected-note{{candidate}}
685 print("d = ", d
..., "\n");
687 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
688 return decltype(a
){};
698 auto L_test
= L('4');
700 auto M_test
= M('a');
702 auto O
= N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
703 char (*np
)(const char*, int, const char*, double, const char*, int) = O
;
704 auto NP_result
= np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
705 int (*np2
)(const char*, int, const char*, double, const char*, int) = O
; // expected-error{{no viable conversion}}
707 } //end at_ns_scope_within_class_member
710 namespace at_ns_scope_within_class_template_member
{
712 static void foo(double d
) { }
713 template<class T
= int>
715 auto L
= [](auto a
) {
716 print("a = ", a
, "\n");
718 return [](decltype(a
) b
) {
720 foo(sizeof(a
) + sizeof(b
));
721 return [](auto ... c
) {
722 print("c = ", c
..., "\n");
724 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
725 return [](decltype(c
) ... d
) ->decltype(a
) { //expected-note{{candidate}}
726 print("d = ", d
..., "\n");
728 foo(sizeof(decltype(a
)*) + sizeof(decltype(b
)*));
729 return decltype(a
){};
740 auto L_test
= L('4');
742 auto M_test
= M('a');
744 auto O
= N("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
745 char (*np
)(const char*, int, const char*, double, const char*, int) = O
;
746 auto NP_result
= np("\n3 = ", 3, "\n6.14 = ", 6.14, "\n4'123'456 = ", 4'123'456);
747 int (*np2
)(const char*, int, const char*, double, const char*, int) = O
; // expected-error{{no viable conversion}}
749 } //end at_ns_scope_within_class_member
752 namespace nested_generic_lambdas_123
{
754 auto L
= [](auto a
) -> int {
755 auto M
= [](auto b
, decltype(a
) b2
) -> int {
762 template<class T
> void foo(T
) {
763 auto L
= [](auto a
) { return a
; };
765 template void foo(int);
766 } // end ns nested_generic_lambdas_123
768 namespace nested_fptr_235
{
771 auto L
= [](auto b
) {
772 return [](auto a
) ->decltype(a
) { return a
; };
774 int (*fp
)(int) = L(8);
777 char (*fc
)(char) = L('a');
780 double (*fd
)(double) = L(3.14);
789 namespace fptr_with_decltype_return_type
{
790 template<class F
, class ... Rest
> F
& FirstArg(F
& f
, Rest
& ... r
) { return f
; };
791 template<class ... Ts
> auto vfun(Ts
&& ... ts
) {
793 return FirstArg(ts
...);
798 auto L
= [](auto ... As
) {
799 return [](auto b
) ->decltype(b
) {
800 vfun([](decltype(As
) a
) -> decltype(a
) { return a
; } ...)(first
<decltype(As
)...>{});
801 return decltype(b
){};
804 auto LL
= L(1, 'a', 3.14, "abc");
812 } // end ns nested_non_capturing_lambda_tests
816 string(const char *__s
) { }
817 string
&operator+=(const string
&__str
) { return *this; }
821 void finalizeDefaultAtomValues() {
822 auto startEnd
= [](const char * sym
) -> void {
826 startEnd("preinit_array");
829 void f() { finalizeDefaultAtomValues
<char>(); }
833 namespace PR17476_variant
{
835 string(const char *__s
) { }
836 string
&operator+=(const string
&__str
) { return *this; }
840 void finalizeDefaultAtomValues() {
841 auto startEnd
= [](const T
*sym
) -> void {
845 startEnd("preinit_array");
848 void f() { finalizeDefaultAtomValues
<char>(); }
852 namespace PR17877_lambda_declcontext_and_get_cur_lambda_disconnect
{
855 template<class T
> struct U
{
861 U
<T
> size() const { return U
<T
>{}; }
872 namespace inclass_lambdas_within_nested_classes
{
877 enum { E
= [](auto i
) { return i
; }(3) }; //expected-error{{inside of a constant expression}}\
878 //expected-error{{constant}}\
879 //expected-note{{non-literal type}}
880 int L
= ([] (int i
) { return i
; })(2);
881 void foo(int i
= ([] (int i
) { return i
; })(2)) { }
882 int B
: ([](int i
) { return i
; })(3); //expected-error{{inside of a constant expression}}\
883 //expected-error{{not an integral constant}}\
884 //expected-note{{non-literal type}}
885 int arr
[([](int i
) { return i
; })(3)]; //expected-error{{inside of a constant expression}}\
886 //expected-error{{must have a constant size}}\
887 //expected-warning{{variable length arrays in C++ are a Clang extension}}\
888 //expected-note-re{{non-literal type '{{.*}}' cannot be used in a constant expression}}
889 int (*fp
)(int) = [](int i
) { return i
; };
890 void fooptr(int (*fp
)(char) = [](char c
) { return 0; }) { }
891 int L2
= ([](auto i
) { return i
; })(2);
892 void fooG(int i
= ([] (auto i
) { return i
; })(2)) { }
893 int BG
: ([](auto i
) { return i
; })(3); //expected-error{{inside of a constant expression}} \
894 //expected-error{{not an integral constant}}\
895 //expected-note{{non-literal type}}
896 int arrG
[([](auto i
) { return i
; })(3)]; //expected-error{{inside of a constant expression}}\
897 //expected-error{{must have a constant size}}\
898 //expected-warning{{variable length arrays in C++ are a Clang extension}}\
899 //expected-note-re{{non-literal type '{{.*}}' cannot be used in a constant expression}}
901 int (*fpG
)(int) = [](auto i
) { return i
; };
902 void fooptrG(int (*fp
)(char) = [](auto c
) { return 0; }) { }
911 int L
= ([] (T i
) { return i
; })(2);
912 void foo(int i
= ([] (int i
) { return i
; })(2)) { }
913 int B
: ([](T i
) { return i
; })(3); //expected-error{{inside of a constant expression}}\
914 //expected-error{{not an integral constant}}\
915 //expected-note{{non-literal type}}
916 int arr
[([](T i
) { return i
; })(3)]; //expected-error{{inside of a constant expression}}\
917 //expected-error{{must have a constant size}}\
918 //expected-warning{{variable length arrays in C++ are a Clang extension}}\
919 //expected-note-re{{non-literal type '{{.*}}' cannot be used in a constant expression}}
921 int (*fp
)(T
) = [](T i
) { return i
; };
922 void fooptr(T (*fp
)(char) = [](char c
) { return 0; }) { }
923 int L2
= ([](auto i
) { return i
; })(2);
924 void fooG(T i
= ([] (auto i
) { return i
; })(2)) { }
925 int BG
: ([](auto i
) { return i
; })(3); //expected-error{{not an integral constant}}\
926 //expected-note{{non-literal type}}\
927 //expected-error{{inside of a constant expression}}
928 int arrG
[([](auto i
) { return i
; })(3)]; //expected-error{{must have a constant size}} \
929 //expected-error{{inside of a constant expression}}\
930 //expected-warning{{variable length arrays in C++ are a Clang extension}}\
931 //expected-note-re{{non-literal type '{{.*}}' cannot be used in a constant expression}}
933 int (*fpG
)(T
) = [](auto i
) { return i
; };
934 void fooptrG(T (*fp
)(char) = [](auto c
) { return 0; }) { }
935 template<class U
= char> int fooG2(T (*fp
)(U
) = [](auto a
) { return 0; }) { return 0; }
936 template<class U
= char> int fooG3(T (*fp
)(U
) = [](auto a
) { return 0; });
941 int X1::X2
<T
>::fooG3(T (*fp
)(U
)) { return 0; }
942 X1::X2
<int> x2
; //expected-note {{in instantiation of}}
943 int run1
= x2
.fooG2();
944 int run2
= x2
.fooG3();
949 } //end ns inclass_lambdas_within_nested_classes
951 namespace pr21684_disambiguate_auto_followed_by_ellipsis_no_id
{
952 int a
= [](auto ...) { return 0; }();
957 return [](auto... run_args
) {
958 using T
= int(decltype(run_args
)...);
965 int y
= [](auto outer
) {
966 return [](auto inner
) {
967 using T
= int(decltype(outer
), decltype(inner
));
976 auto g
= [](auto&&... args
) {
977 auto h
= [args
...]() -> int {
990 void Method(char c
= []()->char {
991 int d
= [](auto x
)->int {
993 int Method() { return 0; }
1002 void Method(char c
= [](auto x
)->char {
1005 int Method() { return 0; }
1014 void Method(char c
= [](auto x
)->char {
1015 int d
= [](auto y
)->int {
1017 int Method() { return 0; }
1027 //https://bugs.llvm.org/show_bug.cgi?id=32638
1029 [](auto x
) noexcept(noexcept(x
)) { } (0);
1034 auto x
= [](auto (*p
)()) { return p(); };
1035 auto y
= [](auto (*p
)() -> auto) { return p(); };
1037 void *v
= x(f
); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
1038 void *w
= y(f
); // expected-error {{cannot initialize a variable of type 'void *' with an rvalue of type 'int'}}
1042 struct A
{ int x
; };
1045 [](auto t
) -> decltype(decltype(t
)::x
) { return 0; }(A());