diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/CodeGen/ms-anonymous-struct.c | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/CodeGen/ms-anonymous-struct.c')
-rw-r--r-- | clang/test/CodeGen/ms-anonymous-struct.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/clang/test/CodeGen/ms-anonymous-struct.c b/clang/test/CodeGen/ms-anonymous-struct.c new file mode 100644 index 0000000..b41caab --- /dev/null +++ b/clang/test/CodeGen/ms-anonymous-struct.c @@ -0,0 +1,99 @@ +// RUN: %clang_cc1 -fms-extensions -emit-llvm -o - %s | FileCheck %s + +// CHECK: %struct.test = type { i32, %struct.nested2, i32 } +// CHECK: %struct.nested2 = type { i32, %struct.nested1, i32 } +// CHECK: %struct.nested1 = type { i32, i32 } +typedef struct nested1 { + int a1; + int b1; +} NESTED1; + +struct nested2 { + int a; + NESTED1; + int b; +}; + +struct test { + int x; + struct nested2; + int y; +}; + + +void foo() +{ + // CHECK: %var = alloca %struct.test, align 4 + struct test var; + + // CHECK: getelementptr inbounds %struct.test* %var, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.a; + + // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.b; + + // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.a1; + + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}var, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.b1; + + // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.x; + + // CHECK-NEXT: getelementptr inbounds %struct.test* %var, i32 0, i32 2 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var.y; +} + +void foo2(struct test* var) +{ + // CHECK: alloca %struct.test*, align + // CHECK-NEXT: store %struct.test* %var, %struct.test** %{{.*}}, align + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->a; + + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 2 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->b; + + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->a1; + + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested2* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: getelementptr inbounds %struct.nested1* %{{.*}}, i32 0, i32 1 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->b1; + + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 0 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->x; + + // CHECK-NEXT: load %struct.test** %{{.*}}, align + // CHECK-NEXT: getelementptr inbounds %struct.test* %{{.*}}, i32 0, i32 2 + // CHECK-NEXT: load i32* %{{.*}}, align 4 + var->y; +} |