aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/const-arithmetic.c
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-20 05:53:45 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-20 05:53:45 +0000
commite0cdb4edd8f265d0fd22d178d03c597dd201cda2 (patch)
tree4ff2a875da1d9c535c0c069552636f4fb85275a9 /test/CodeGen/const-arithmetic.c
parent0a80ba74ffa3d3df55abfbc4474d7470c7c923e3 (diff)
Evaluate: Fix a subtle bug in the pointer evaluator in which we would do an
expression computation in the wrong bit-width, and end up generating a totally bogus array reference (_g0+8589934546). - This showed up on Prolangs/cdecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99042 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/const-arithmetic.c')
-rw-r--r--test/CodeGen/const-arithmetic.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/CodeGen/const-arithmetic.c b/test/CodeGen/const-arithmetic.c
new file mode 100644
index 0000000000..e12b4f6d92
--- /dev/null
+++ b/test/CodeGen/const-arithmetic.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 8 ; <[2 x i8*]*> [#uses=0]
+// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 8 ; <[2 x i8*]*> [#uses=0]
+
+extern struct { unsigned char a, b; } g0[];
+void *g1[] = {g0 + -1, g0 + -23 };
+void *g2[] = {g0 - 1, g0 - 23 };