blob: 0ce1431c76fff2b544c86e7b127dcd53b50bf7a1 [file] [log] [blame]
Daniel Dunbarfd089992009-06-26 16:47:03 +00001//===-- gcc_personality_test.c - Tests __gcc_personality_v0 -------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10
11#include <stdlib.h>
12#include <stdio.h>
13
14extern void foo_clean(void* x);
15extern void bar_clean(void* x);
16extern void register_foo_local(int* x);
17extern void register_bar_local(int* x);
18extern void done_foo();
19extern void done_bar();
20
21
22//
23// foo() is called by main() in gcc_personality_test_helper.cxx.
24// done_bar() is implemented in C++ and will throw an exception.
25// main() will catch the exception and verify that the cleanup
26// routines for foo() and bar() were called by the personality
27// function.
28//
29
30
31void bar()
32{
33 int x __attribute__((cleanup(bar_clean))) = 0;
34 register_bar_local(&x);
35 done_bar();
36}
37
38void foo()
39{
40 int x __attribute__((cleanup(foo_clean))) = 0;
41 register_foo_local(&x);
42 bar();
43 done_foo();
44}
45
46