2015-10-08 12:24:12 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-gnu %s -o - | FileCheck %s
|
2014-04-10 13:20:00 +08:00
|
|
|
|
|
|
|
// Make sure that we emit a global variable for each of the members of the
|
|
|
|
// anonymous union.
|
|
|
|
|
|
|
|
static union {
|
|
|
|
int c;
|
|
|
|
int d;
|
|
|
|
union {
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
int test_it() {
|
|
|
|
c = 1;
|
|
|
|
d = 2;
|
|
|
|
a = 4;
|
|
|
|
return (c == 1);
|
|
|
|
}
|
|
|
|
|
2015-04-30 00:52:31 +08:00
|
|
|
void foo() {
|
|
|
|
union {
|
|
|
|
int i;
|
|
|
|
char c;
|
|
|
|
};
|
|
|
|
i = 8;
|
|
|
|
}
|
|
|
|
|
2015-11-21 01:41:12 +08:00
|
|
|
// A funky reinterpret cast idiom that we used to crash on.
|
|
|
|
template <class T>
|
|
|
|
unsigned char *buildBytes(const T v) {
|
|
|
|
static union {
|
|
|
|
unsigned char result[sizeof(T)];
|
|
|
|
T value;
|
|
|
|
};
|
|
|
|
value = v;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void instantiate(int x) {
|
|
|
|
buildBytes(x);
|
|
|
|
}
|
|
|
|
|
2015-04-30 00:40:08 +08:00
|
|
|
// CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",
|
|
|
|
// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
|
|
// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
|
|
// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
|
|
|
// CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
|
2015-11-21 01:41:12 +08:00
|
|
|
// CHECK: !DIGlobalVariable(name: "result", {{.*}} isLocal: false, isDefinition: true
|
|
|
|
// CHECK: !DIGlobalVariable(name: "value", {{.*}} isLocal: false, isDefinition: true
|
2015-08-01 02:59:37 +08:00
|
|
|
// CHECK: !DILocalVariable(name: "i", {{.*}}, flags: DIFlagArtificial
|
|
|
|
// CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial
|
2015-04-30 00:52:31 +08:00
|
|
|
// CHECK: !DILocalVariable(
|
|
|
|
// CHECK-NOT: name:
|
|
|
|
// CHECK: type: ![[UNION:[0-9]+]]
|
|
|
|
// CHECK: ![[UNION]] = !DICompositeType(tag: DW_TAG_union_type,
|
|
|
|
// CHECK-NOT: name:
|
|
|
|
// CHECK: elements
|
|
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],
|
|
|
|
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],
|