xref: /llvm-project/clang/test/SemaCXX/no-exceptions.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 // Various tests for -fno-exceptions
4 
5 typedef __SIZE_TYPE__ size_t;
6 
7 namespace test0 {
8   class Foo {
9   public:
10     void* operator new(size_t x);
11   private:
12     void operator delete(void *x);
13   };
14 
test()15   void test() {
16     // Under -fexceptions, this does access control for the associated
17     // 'operator delete'.
18     (void) new Foo();
19   }
20 }
21 
22 namespace test1 {
f()23 void f() {
24   throw; // expected-error {{cannot use 'throw' with exceptions disabled}}
25 }
26 
g()27 void g() {
28   try { // expected-error {{cannot use 'try' with exceptions disabled}}
29     f();
30   } catch (...) {
31   }
32 }
33 
34 }
35