diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-15 18:49:47 +0000 | 
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-12-15 18:49:47 +0000 | 
| commit | 34d02d0b37f16015f317a935c48ce8b7b64ae77b (patch) | |
| tree | 2fd5819f49caecc5f520219b6b9254fe94ebb138 /test/CodeGen/decl.c | |
| parent | 1569ce68681d909594d64f9b056d71f5dd7563bf (diff) | |
Notes
Diffstat (limited to 'test/CodeGen/decl.c')
| -rw-r--r-- | test/CodeGen/decl.c | 61 | 
1 files changed, 61 insertions, 0 deletions
diff --git a/test/CodeGen/decl.c b/test/CodeGen/decl.c new file mode 100644 index 0000000000000..f7a001e47ce4a --- /dev/null +++ b/test/CodeGen/decl.c @@ -0,0 +1,61 @@ +// RUN: clang-cc -emit-llvm < %s | FileCheck %s + +// CHECK: @test1.x = internal constant [12 x i32] [i32 1 +// CHECK: @test2.x = internal constant [13 x i32] [i32 1, +// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef } +// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 } + +void test1() { +  // This should codegen as a "@test1.x" global. +  const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 }; +  foo(x); + +// CHECK: @test1() +// CHECK: {{call.*@foo.*@test1.x}} +} + + +// rdar://7346691 +void test2() { +  // This should codegen as a "@test2.x" global + memcpy. +  int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23, 24 }; +  foo(x); +   +  // CHECK: @test2() +  // CHECK: %x = alloca [13 x i32] +  // CHECK: call void @llvm.memcpy +  // CHECK: call{{.*}}@foo{{.*}}i32* % +} + + +void test3() { +  // This should codegen as a memset. +  int x[100] = { 0 }; +  foo(x); +   +  // CHECK: @test3() +  // CHECK: %x = alloca [100 x i32] +  // CHECK: call void @llvm.memset +} + +void test4(void) { +  char a[10] = "asdf"; +  char b[10] = { "asdf" }; +  // CHECK: @test4() +  // CHECK: %a = alloca [10 x i8] +  // CHECK: %b = alloca [10 x i8] +  // CHECK: call void @llvm.memcpy +  // CHECK: call void @llvm.memcpy +} + + +union test5u { int i; double d; }; + +void test5() { +  union test5u ola = (union test5u) 351; +  union test5u olb = (union test5u) 1.0; +} + +union test5u test5w = (union test5u)2; +union test5u test5y = (union test5u)73.0; +  | 
