In the wake of https://reviews.llvm.org/D89559, we discovered that a couple of tests (the ones modified below to have additional triple versions) would fail on Win32, for 1 of two reasons. We seem to not have a win32 buildbot anymore, so the triple is to make sure this doesn't get broken in the future. First, two of the three 'note-candidate' functions weren't appropriately skipping the remaining conversion functions. Second, in 1 situation (note surrogate candidates) we actually print the type of the conversion operator. The two tests that ran into that needed updating to make sure it printed the proper one in the win32 case.
56 lines
2.3 KiB
C++
56 lines
2.3 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify=expected,nowin32
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify=expected,win32 -triple i386-windows
|
|
|
|
void defargs() {
|
|
auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
|
|
int i1 = l1(1);
|
|
int i2 = l1(1, 2);
|
|
int i3 = l1(1, 2, 3);
|
|
}
|
|
|
|
|
|
void defargs_errors() {
|
|
auto l1 = [](int i,
|
|
int j = 17,
|
|
int k) { }; // expected-error{{missing default argument on parameter 'k'}}
|
|
|
|
auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}}
|
|
|
|
int foo;
|
|
auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}}
|
|
}
|
|
|
|
struct NonPOD {
|
|
NonPOD();
|
|
NonPOD(const NonPOD&);
|
|
~NonPOD();
|
|
};
|
|
|
|
struct NoDefaultCtor {
|
|
NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} \
|
|
// expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}}
|
|
~NoDefaultCtor();
|
|
};
|
|
|
|
template<typename T>
|
|
void defargs_in_template_unused(T t) {
|
|
auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
|
|
l1(t);
|
|
}
|
|
|
|
template void defargs_in_template_unused(NonPOD);
|
|
template void defargs_in_template_unused(NoDefaultCtor); // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused<NoDefaultCtor>' requested here}}
|
|
|
|
template<typename T>
|
|
void defargs_in_template_used() {
|
|
auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \
|
|
// expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}} \
|
|
// nowin32-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}}\
|
|
// win32-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &) __attribute__((thiscall))'}}
|
|
l1(); // expected-error{{no matching function for call to object of type '(lambda at }}
|
|
}
|
|
|
|
template void defargs_in_template_used<NonPOD>();
|
|
template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}}
|
|
|