aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/const-init.c
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-19 22:24:01 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-19 22:24:01 +0000
commitdd2116462ae311043986ae8b7fba27e68c1b2e66 (patch)
tree59d458a936f5d0d54b12a14087aff5aa3d9a767d /test/CodeGen/const-init.c
parentb92dac8bc2f6f73919825f9af693a8a7e89ae1d4 (diff)
Extend Evaluate() to fold (int) <pointer type>.
- PR3463, PR3398, <rdar://problem/6553401> crash on relocatable symbol addresses as constants in static locals. - There are many more scenarious we could handle (like arithmetic on such an int) but this is the main use case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/const-init.c')
-rw-r--r--test/CodeGen/const-init.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c
index c98cfd4ca2..957e3733e4 100644
--- a/test/CodeGen/const-init.c
+++ b/test/CodeGen/const-init.c
@@ -48,4 +48,32 @@ int g9 = (2 + 3i) * (5 + 7i) != (-11 + 29i);
int g10 = (2.0 + 3.0i) * (5.0 + 7.0i) != (-11.0 + 29.0i);
+// Global references
+// RUN: grep '@g11.l0 = internal global i32 ptrtoint (i32 ()\* @g11 to i32)' %t &&
+long g11() {
+ static long l0 = (long) g11;
+ return l0;
+}
+
+// RUN: grep '@g12 = global i32 ptrtoint (i8\* @g12_tmp to i32)' %t &&
+static char g12_tmp;
+long g12 = (long) &g12_tmp;
+
+// RUN: grep '@g13 = global \[1 x .struct.g13_s0\] \[.struct.g13_s0 <{ i32 ptrtoint (i8\* @g12_tmp to i32) }>\]' %t &&
+struct g13_s0 {
+ long a;
+};
+struct g13_s0 g13[] = {
+ { (long) &g12_tmp }
+};
+
+// RUN: grep '@g14 = global i8\* inttoptr (i64 100 to i8\*)' %t &&
+void *g14 = (void*) 100;
+
+// RUN: grep '@g15 = global i32 -1' %t &&
+int g15 = (int) (char) ((void*) 0 + 255);
+
+// RUN: grep '@g16 = global i64 4294967295' %t &&
+long long g16 = (long long) ((void*) 0xFFFFFFFF);
+
// RUN: true