[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / debug-info-anon-union-vars.cpp
blob61b3c7c0526c8ef2da867889c734c543aeb17554
1 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-gnu %s -o - | FileCheck %s
3 // Make sure that we emit a global variable for each of the members of the
4 // anonymous union.
6 static union {
7 int c;
8 int d;
9 union {
10 int a;
12 struct {
13 int b;
17 int test_it() {
18 c = 1;
19 d = 2;
20 a = 4;
21 return (c == 1);
24 void foo() {
25 union {
26 int i;
27 char c;
29 i = 8;
32 // A funky reinterpret cast idiom that we used to crash on.
33 template <class T>
34 unsigned char *buildBytes(const T v) {
35 static union {
36 unsigned char result[sizeof(T)];
37 T value;
39 value = v;
40 return result;
43 void instantiate(int x) {
44 buildBytes(x);
47 // CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE:.*]], line: 6,{{.*}} isLocal: true, isDefinition: true
48 // CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
49 // CHECK: [[FILE]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",
50 // CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
51 // CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true
52 // CHECK: !DIGlobalVariable(name: "result", {{.*}} isLocal: false, isDefinition: true
53 // CHECK: !DIGlobalVariable(name: "value", {{.*}} isLocal: false, isDefinition: true
54 // CHECK: !DILocalVariable(name: "i", {{.*}}, flags: DIFlagArtificial
55 // CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial
56 // CHECK: !DILocalVariable(
57 // CHECK-NOT: name:
58 // CHECK: type: ![[UNION:[0-9]+]]
59 // CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,
60 // CHECK-NOT: name:
61 // CHECK: elements
62 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],
63 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],