brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 8d27f1c Raw
60 lines · cpp
1// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++23 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++20 -fsyntax-only -verify %s3// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fsyntax-only -verify %s4class X {5  X(const X&);6 7public:8  X();9  X(X&&);10};11 12X return_by_move(int i, X x) {13  X x2;14  if (i == 0)15    return x;16  else if (i == 1)17    return x2;18  else19    return x;20}21 22void throw_move_only(X x) {23  X x2;24  throw x;25  throw x2;26}27 28namespace PR10142 {29  struct X {30    X();31    X(X&&);32    X(const X&) = delete; // expected-note 2{{'X' has been explicitly marked deleted here}}33  };34 35  void f(int i) {36    X x;37    try {38      X x2;39      if (i)40        throw x2; // okay41      throw x; // expected-error{{call to deleted constructor of 'X'}}42    } catch (...) {43    }44  }45 46  template<typename T>47  void f2(int i) {48    T x;49    try {50      T x2;51      if (i)52        throw x2; // okay53      throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}}54    } catch (...) {55    }56  }57 58  template void f2<X>(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2<PR10142::X>' requested here}}59}60