| 1 |
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify %s |
| 2 |
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify %s |
| 3 |
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s |
| 4 |
// expected-no-diagnostics |
| 5 |
|
| 6 |
// Throwing |
| 7 |
namespace test_throwing { |
| 8 |
class Widget { |
| 9 |
public: |
| 10 |
Widget(Widget &&); |
| 11 |
Widget(const Widget &) = delete; |
| 12 |
}; |
| 13 |
|
| 14 |
void seven(Widget w) { |
| 15 |
throw w; |
| 16 |
} |
| 17 |
} // namespace test_throwing |
| 18 |
|
| 19 |
// Non-constructor conversion |
| 20 |
namespace test_non_constructor_conversion { |
| 21 |
class Widget {}; |
| 22 |
|
| 23 |
struct To { |
| 24 |
operator Widget() const & = delete; |
| 25 |
operator Widget() &&; |
| 26 |
}; |
| 27 |
|
| 28 |
Widget nine() { |
| 29 |
To t; |
| 30 |
return t; |
| 31 |
} |
| 32 |
} // namespace test_non_constructor_conversion |
| 33 |
|
| 34 |
// By-value sinks |
| 35 |
namespace test_by_value_sinks { |
| 36 |
class Widget { |
| 37 |
public: |
| 38 |
Widget(); |
| 39 |
Widget(Widget &&); |
| 40 |
Widget(const Widget &) = delete; |
| 41 |
}; |
| 42 |
|
| 43 |
struct Fowl { |
| 44 |
Fowl(Widget); |
| 45 |
}; |
| 46 |
|
| 47 |
Fowl eleven() { |
| 48 |
Widget w; |
| 49 |
return w; |
| 50 |
} |
| 51 |
} // namespace test_by_value_sinks |
| 52 |
|
| 53 |
// Slicing |
| 54 |
namespace test_slicing { |
| 55 |
class Base { |
| 56 |
public: |
| 57 |
Base(); |
| 58 |
Base(Base &&); |
| 59 |
Base(Base const &) = delete; |
| 60 |
}; |
| 61 |
|
| 62 |
class Derived : public Base {}; |
| 63 |
|
| 64 |
Base thirteen() { |
| 65 |
Derived result; |
| 66 |
return result; |
| 67 |
} |
| 68 |
} // namespace test_slicing |