1// FIXME: UNSUPPORTED as currently it cannot be built by lit properly.
2// UNSUPPORTED: true
3// RUN: %clangxx_builtins %s %librt -o %t && %run %t
4
5#include <stdlib.h>
6#include <stdio.h>
7
8extern void foo_clean(void* x);
9extern void bar_clean(void* x);
10extern void register_foo_local(int* x);
11extern void register_bar_local(int* x);
12extern void done_foo();
13extern void done_bar();
14
15
16/*
17 * foo() is called by main() in gcc_personality_test_helper.cxx.
18 * done_bar() is implemented in C++ and will throw an exception.
19 * main() will catch the exception and verify that the cleanup
20 * routines for foo() and bar() were called by the personality
21 * function.
22 */
23
24void bar() {
25 int x __attribute__((cleanup(bar_clean))) = 0;
26 register_bar_local(x: &x);
27 done_bar();
28}
29
30void foo() {
31 int x __attribute__((cleanup(foo_clean))) = 0;
32 register_foo_local(x: &x);
33 bar();
34 done_foo();
35}
36

source code of compiler-rt/test/builtins/Unit/gcc_personality_test.c