| 1 |
// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -fsyntax-only -verify %s |
| 2 |
|
| 3 |
namespace GH49266 { |
| 4 |
struct X { |
| 5 |
X() = default; |
| 6 |
X(X const&) = delete; // expected-note {{'X' has been explicitly marked deleted here}} |
| 7 |
}; |
| 8 |
|
| 9 |
void take_by_copy(auto &...args) { |
| 10 |
[...args = args] {}(); // expected-error {{call to deleted constructor}} |
| 11 |
} |
| 12 |
|
| 13 |
void take_by_ref(auto &...args) { |
| 14 |
[&...args = args] {}(); // args is passed by reference and not copied. |
| 15 |
} |
| 16 |
|
| 17 |
void foo() { |
| 18 |
X x; |
| 19 |
take_by_copy(x); // expected-note {{in instantiation of function template specialization}} |
| 20 |
take_by_ref(x); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
namespace GH48937 { |
| 25 |
|
| 26 |
template <typename... Ts> |
| 27 |
consteval int f(Ts... ts) { |
| 28 |
return ([]<Ts a = 42>(){ return a;}, ...)(); |
| 29 |
} |
| 30 |
|
| 31 |
static_assert(f(0, 42) == 42); |
| 32 |
|
| 33 |
template <typename Ts> |
| 34 |
int g(Ts ts) { |
| 35 |
return ([]<Ts a = 42>(){ return a;}, ...)(); // expected-error {{pack expansion does not contain any unexpanded parameter packs}} |
| 36 |
} |
| 37 |
|
| 38 |
template <typename... Ts> |
| 39 |
int h(Ts... ts) { |
| 40 |
return ([]<Ts a = 42>(){ return a;})(); // expected-error {{expression contains unexpanded parameter pack 'Ts'}} |
| 41 |
} |
| 42 |
|
| 43 |
} |