xref: /llvm-project/clang/test/SemaCXX/assume-nothrow-exception-dtor.cpp (revision c0a73918bfddc6a04a897aab57fb95e8d2da7ec0)
1 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only %s -fcxx-exceptions -fassume-nothrow-exception-dtor -verify
2 
3 namespace test1 {
4 template <typename T> struct A { A(); ~A(); };
5 struct B { ~B() noexcept(false); };
6 struct B1 : B {};
7 struct B2 { B b; };
8 struct C { virtual void f(); } c;
9 struct MoveOnly { MoveOnly(); MoveOnly(MoveOnly&&); };
run()10 void run() {
11   throw A<int>();
12   throw B();  // expected-error{{cannot throw object of type 'B' with a potentially-throwing destructor}}
13   throw new B;
14   throw B1(); // expected-error{{cannot throw object of type 'B1' with a potentially-throwing destructor}}
15   B2 b2;
16   throw b2;   // expected-error{{cannot throw object of type 'B2' with a potentially-throwing destructor}}
17   throw c;
18   MoveOnly m;
19   throw m;
20 }
21 }
22