Mercurial > hg > CbC > CbC_llvm
comparison clang/test/CodeGenCXX/const-init.cpp @ 252:1f2b6ac9f198 llvm-original
LLVM16-1
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Aug 2023 09:04:13 +0900 |
parents | c4bab56944e8 |
children |
comparison
equal
deleted
inserted
replaced
237:c80f45b162ad | 252:1f2b6ac9f198 |
---|---|
1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s | 1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s |
2 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin -emit-llvm -std=c++98 -o - %s | FileCheck %s | 2 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++98 -o - %s | FileCheck %s |
3 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin -emit-llvm -std=c++11 -o - %s | FileCheck %s | 3 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++11 -o - %s | FileCheck %s |
4 | 4 |
5 // CHECK: @a = global i32 10 | 5 // CHECK: @a = global i32 10 |
6 int a = 10; | 6 int a = 10; |
7 // CHECK: @ar = constant i32* @a | 7 // CHECK: @ar = constant ptr @a |
8 int &ar = a; | 8 int &ar = a; |
9 | 9 |
10 void f(); | 10 void f(); |
11 // CHECK: @fr = constant void ()* @_Z1fv | 11 // CHECK: @fr = constant ptr @_Z1fv |
12 void (&fr)() = f; | 12 void (&fr)() = f; |
13 | 13 |
14 struct S { int& a; }; | 14 struct S { int& a; }; |
15 // CHECK: @s = global %struct.S { i32* @a } | 15 // CHECK: @s = global %struct.S { ptr @a } |
16 S s = { a }; | 16 S s = { a }; |
17 | 17 |
18 // PR5581 | 18 // PR5581 |
19 namespace PR5581 { | 19 namespace PR5581 { |
20 class C { | 20 class C { |
39 static int g(); | 39 static int g(); |
40 } a; | 40 } a; |
41 | 41 |
42 // CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8 | 42 // CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8 |
43 // CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16 | 43 // CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16 |
44 // CHECK: @_ZN5test22t2E = global double* @_ZN5test21A1d | 44 // CHECK: @_ZN5test22t2E = global ptr @_ZN5test21A1d |
45 // CHECK: @_ZN5test22t3E = global {{.*}} @_ZN5test21A1g | 45 // CHECK: @_ZN5test22t3E = global {{.*}} @_ZN5test21A1g |
46 double t0 = A::d; | 46 double t0 = A::d; |
47 double t1[] = { A::d, A::f }; | 47 double t1[] = { A::d, A::f }; |
48 const double *t2 = &a.d; | 48 const double *t2 = &a.d; |
49 int (*t3)() = &a.g; | 49 int (*t3)() = &a.g; |
72 // Make sure we don't try to fold this either. | 72 // Make sure we don't try to fold this either. |
73 // CHECK: @_ZZ23UnfoldableAddrLabelDiffvE1x = internal global i128 0 | 73 // CHECK: @_ZZ23UnfoldableAddrLabelDiffvE1x = internal global i128 0 |
74 void UnfoldableAddrLabelDiff() { static __int128_t x = (long)&&a-(long)&&b; a:b:return;} | 74 void UnfoldableAddrLabelDiff() { static __int128_t x = (long)&&a-(long)&&b; a:b:return;} |
75 | 75 |
76 // But make sure we do fold this. | 76 // But make sure we do fold this. |
77 // CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (i8* blockaddress(@_Z21FoldableAddrLabelDiffv | 77 // CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (ptr blockaddress(@_Z21FoldableAddrLabelDiffv |
78 void FoldableAddrLabelDiff() { static long x = (long)&&a-(long)&&b; a:b:return;} | 78 void FoldableAddrLabelDiff() { static long x = (long)&&a-(long)&&b; a:b:return;} |
79 | 79 |
80 // CHECK: @i = constant i32* bitcast (float* @PR9558 to i32*) | 80 // CHECK: @i = constant ptr @PR9558 |
81 int &i = reinterpret_cast<int&>(PR9558); | 81 int &i = reinterpret_cast<int&>(PR9558); |
82 | 82 |
83 int arr[2]; | 83 int arr[2]; |
84 // CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8, i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*) | 84 // CHECK: @pastEnd = constant ptr getelementptr (i8, ptr @arr, i64 8) |
85 int &pastEnd = arr[2]; | 85 int &pastEnd = arr[2]; |
86 | 86 |
87 // CHECK: @[[WCHAR_STR:.*]] = internal global [2 x i32] [i32 112, i32 0], | 87 // CHECK: @[[WCHAR_STR:.*]] = internal global [2 x i32] [i32 112, i32 0], |
88 // CHECK: @PR51105_a = global i32* {{.*}} @[[WCHAR_STR]], | 88 // CHECK: @PR51105_a = global ptr @[[WCHAR_STR]], |
89 wchar_t *PR51105_a = (wchar_t[2]){ (L"p") }; | 89 wchar_t *PR51105_a = (wchar_t[2]){ (L"p") }; |
90 // CHECK: @[[CHAR_STR:.*]] = internal global [5 x i8] c"p\00\00\00\00", | 90 // CHECK: @[[CHAR_STR:.*]] = internal global [5 x i8] c"p\00\00\00\00", |
91 // CHECK: @PR51105_b = global i8* {{.*}} @[[CHAR_STR]], | 91 // CHECK: @PR51105_b = global ptr @[[CHAR_STR]], |
92 char *PR51105_b = (char [5]){ ("p") }; | 92 char *PR51105_b = (char [5]){ ("p") }; |
93 | 93 |
94 struct X { | 94 struct X { |
95 long n : 8; | 95 long n : 8; |
96 }; | 96 }; |
97 long k; | 97 long k; |
98 X x = {(long)&k}; | 98 X x = {(long)&k}; |
99 // CHECK: store i8 ptrtoint (i64* @k to i8), i8* getelementptr inbounds (%struct.X, %struct.X* @x, i32 0, i32 0) | 99 // CHECK: store i8 ptrtoint (ptr @k to i8), ptr @x |