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