1 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -triple i386-windows
5 auto l1
= [](int i
, int j
= 17, int k
= 18) { return i
+ j
+ k
; };
12 void defargs_errors() {
15 int k
) { }; // expected-error{{missing default argument on parameter 'k'}}
17 auto l2
= [](int i
, int j
= i
) {}; // expected-error{{default argument references parameter 'i'}}
20 auto l3
= [](int i
= foo
) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}}
25 NonPOD(const NonPOD
&);
29 struct NoDefaultCtor
{
30 NoDefaultCtor(const NoDefaultCtor
&); // expected-note{{candidate constructor}} \
31 // expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}}
36 void defargs_in_template_unused(T t
) {
37 auto l1
= [](const T
& value
= T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
41 template void defargs_in_template_unused(NonPOD
);
42 template void defargs_in_template_unused(NoDefaultCtor
); // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused<NoDefaultCtor>' requested here}}
45 void defargs_in_template_used() {
46 auto l1
= [](const T
& value
= T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \
47 // expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}}
48 #if defined(_WIN32) && !defined(_WIN64)
49 // expected-note@46{{conversion candidate of type 'void (*)(const NoDefaultCtor &) __attribute__((thiscall))'}}
51 // expected-note@46{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}}
53 l1(); // expected-error{{no matching function for call to object of type '(lambda at }}
56 template void defargs_in_template_used
<NonPOD
>();
57 template void defargs_in_template_used
<NoDefaultCtor
>(); // expected-note{{in instantiation of function template specialization}}