| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
// RUN: %clang_cc1 -std=c++23 -verify -fsyntax-only %s |
| 3 |
|
| 4 |
enum copy_traits { movable = 1 }; |
| 5 |
|
| 6 |
template <int> |
| 7 |
struct optional_ctor_base {}; |
| 8 |
template <typename T> |
| 9 |
struct ctor_copy_traits { |
| 10 |
// this would produce a c++98-compat warning, which would erroneously get the |
| 11 |
// no-matching-function-call error's notes attached to it (or suppress those |
| 12 |
// notes if this diagnostic was suppressed, as it is in this case) |
| 13 |
static constexpr int traits = copy_traits::movable; |
| 14 |
}; |
| 15 |
template <typename T> |
| 16 |
struct optional : optional_ctor_base<ctor_copy_traits<T>::traits> { |
| 17 |
template <typename U> |
| 18 |
constexpr optional(U&& v); |
| 19 |
}; |
| 20 |
struct A {}; |
| 21 |
struct XA { |
| 22 |
XA(const A&); |
| 23 |
}; |
| 24 |
struct B {}; |
| 25 |
struct XB { |
| 26 |
XB(const B&); |
| 27 |
XB(const optional<B>&); |
| 28 |
}; |
| 29 |
struct YB : XB { |
| 30 |
using XB::XB; |
| 31 |
}; |
| 32 |
void InsertRow(const XA&, const YB&); // expected-note {{candidate function not viable: no known conversion from 'int' to 'const XA' for 1st argument}} |
| 33 |
void ReproducesBugSimply() { |
| 34 |
InsertRow(3, B{}); // expected-error {{no matching function for call to 'InsertRow'}} |
| 35 |
} |
| 36 |
|
| 37 |
#if __cplusplus >= 202302L |
| 38 |
namespace overloadCheck{ |
| 39 |
template<typename T> |
| 40 |
concept AlwaysTrue = true; |
| 41 |
|
| 42 |
struct S { |
| 43 |
int f(AlwaysTrue auto) { return 1; } |
| 44 |
void f(this S&&, auto) {} |
| 45 |
|
| 46 |
void g(auto) {} |
| 47 |
int g(this S&&,AlwaysTrue auto) {return 1;} |
| 48 |
|
| 49 |
int h(AlwaysTrue auto) { return 1; } //expected-note {{previous definition is here}} |
| 50 |
int h(this S&&,AlwaysTrue auto) { // expected-error {{class member cannot be redeclared}} |
| 51 |
return 1; |
| 52 |
} |
| 53 |
}; |
| 54 |
|
| 55 |
int main() { |
| 56 |
int x = S{}.f(0); |
| 57 |
int y = S{}.g(0); |
| 58 |
} |
| 59 |
} |
| 60 |
#endif |
| 61 |
|
| 62 |
namespace GH93076 { |
| 63 |
template <typename ...a> int b(a..., int); // expected-note-re 3 {{candidate function template not viable: no known conversion from 'int ()' to 'int' for {{.*}} argument}} |
| 64 |
int d() { |
| 65 |
(void)b<int, int>(0, 0, d); // expected-error {{no matching function for call to 'b'}} |
| 66 |
(void)b<int, int>(0, d, 0); // expected-error {{no matching function for call to 'b'}} |
| 67 |
(void)b<int, int>(d, 0, 0); // expected-error {{no matching function for call to 'b'}} |
| 68 |
return 0; |
| 69 |
} |
| 70 |
} |