]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGenCXX/static-init.cpp
Update clang to r103004.
[FreeBSD/FreeBSD.git] / test / CodeGenCXX / static-init.cpp
1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3 // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
4
5 // CHECK: @_ZZ2h2vE1i = weak global i32 0
6 // CHECK: @_ZGVZ2h2vE1i = weak global i64 0
7
8 struct A {
9   A();
10   ~A();
11 };
12
13 void f() {
14   // CHECK: call void @_ZN1AC1Ev(
15   // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
16   static A a;
17 }
18
19 void g() {
20   // CHECK: call noalias i8* @_Znwm(i64 1)
21   // CHECK: call void @_ZN1AC1Ev(
22   static A& a = *new A;
23 }
24
25 int a();
26 void h() {
27   static const int i = a();
28 }
29
30 inline void h2() {
31   static int i = a();
32 }
33
34 void h3() {
35   h2();
36 }
37
38 // PR6980: this shouldn't crash
39 namespace test0 {
40   struct A { A(); };
41   __attribute__((noreturn)) int throw_exception();
42
43   void test() {
44     throw_exception();
45     static A r;
46   }
47 }