brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 3277a17 Raw
71 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++23 -verify -fsyntax-only %s3 4enum copy_traits { movable = 1 };5 6template <int>7struct optional_ctor_base {};8template <typename T>9struct ctor_copy_traits {10  // this would produce a c++98-compat warning, which would erroneously get the11  // no-matching-function-call error's notes attached to it (or suppress those12  // notes if this diagnostic was suppressed, as it is in this case)13  static constexpr int traits = copy_traits::movable;14};15template <typename T>16struct optional : optional_ctor_base<ctor_copy_traits<T>::traits> {17  template <typename U>18  constexpr optional(U&& v);19};20struct A {};21struct XA {22  XA(const A&);23};24struct B {};25struct XB {26  XB(const B&);27  XB(const optional<B>&);28};29struct YB : XB {30  using XB::XB;31};32void InsertRow(const XA&, const YB&); // expected-note {{candidate function not viable: no known conversion from 'int' to 'const XA' for 1st argument}}33void ReproducesBugSimply() {34  InsertRow(3, B{}); // expected-error {{no matching function for call to 'InsertRow'}}35}36 37#if __cplusplus >= 202302L38namespace 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#endif61 62namespace GH93076 {63template <typename ...a> int b(a..., int); // expected-note-re 3 {{candidate function template not viable: no known conversion from 'int ()' to 'int' for {{.*}} argument}}64int 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}71