]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/builtins/Unit/gcc_personality_test.c
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / builtins / Unit / gcc_personality_test.c
CommitLineData
1a4d82fc
JJ
1/* ===-- gcc_personality_test.c - Tests __gcc_personality_v0 -------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
7 *
8 * ===----------------------------------------------------------------------===
9 */
10
11
12#include <stdlib.h>
13#include <stdio.h>
14
15extern void foo_clean(void* x);
16extern void bar_clean(void* x);
17extern void register_foo_local(int* x);
18extern void register_bar_local(int* x);
19extern void done_foo();
20extern void done_bar();
21
22
23/*
24 * foo() is called by main() in gcc_personality_test_helper.cxx.
25 * done_bar() is implemented in C++ and will throw an exception.
26 * main() will catch the exception and verify that the cleanup
27 * routines for foo() and bar() were called by the personality
28 * function.
29 */
30
31void bar() {
32 int x __attribute__((cleanup(bar_clean))) = 0;
33 register_bar_local(&x);
34 done_bar();
35}
36
37void foo() {
38 int x __attribute__((cleanup(foo_clean))) = 0;
39 register_foo_local(&x);
40 bar();
41 done_foo();
42}