brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 3aca4e1 Raw
64 lines · cpp
1// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-linux-gnu %s -o - | FileCheck %s2 3// Make sure that we emit a global variable for each of the members of the4// anonymous union.5 6static union {7  int c;8  int d;9  union {10    int a;11  };12  struct {13    int b;14  };15};16 17int test_it() {18  c = 1;19  d = 2;20  a = 4;21  return (c == 1);22}23 24void foo() {25  union {26    int i;27    char c;28  };29  i = 8;30}31 32// A funky reinterpret cast idiom that we used to crash on.33template <class T>34unsigned char *buildBytes(const T v) {35  static union {36    unsigned char result[sizeof(T)];37    T value;38  };39  value = v;40  return result;41}42 43void instantiate(int x) {44  buildBytes(x);45}46 47// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE:.*]], line: 6,{{.*}} isLocal: true, isDefinition: true48// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true49// CHECK: [[FILE]] = !DIFile(filename: "{{.*}}anon-union-vars.cpp",50// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true51// CHECK: !DIGlobalVariable(name: "b",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true52// CHECK: !DIGlobalVariable(name: "result", {{.*}} isLocal: false, isDefinition: true53// CHECK: !DIGlobalVariable(name: "value", {{.*}} isLocal: false, isDefinition: true54// CHECK: !DILocalVariable(name: "i", {{.*}}, flags: DIFlagArtificial55// CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial56// 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: elements62// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],63// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],64