1 // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s 2 3 enum class A { A1=1 }; // underlying type is int by default 4 enum class B: unsigned long { B1=1 }; // underlying type is unsigned long 5 enum C { C1 = 1 }; 6 enum D : short; // enum forward declaration 7 A a; 8 B b; 9 C c; 10 D d; 11 12 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "A" 13 // CHECK-SAME: line: 3 14 // CHECK-SAME: baseType: ![[INT:[0-9]+]] 15 // CHECK-SAME: size: 32, align: 32 16 // CHECK-NOT: offset: 17 // CHECK-NOT: flags: 18 // CHECK-SAME: ){{$}} 19 // CHECK: ![[INT]] = !MDBasicType(name: "int" 20 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "B" 21 // CHECK-SAME: line: 4 22 // CHECK-SAME: baseType: ![[ULONG:[0-9]+]] 23 // CHECK-SAME: size: 64, align: 64 24 // CHECK-NOT: offset: 25 // CHECK-NOT: flags: 26 // CHECK-SAME: ){{$}} 27 // CHECK: ![[ULONG]] = !MDBasicType(name: "long unsigned int" 28 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "C" 29 // CHECK-SAME: line: 5 30 // CHECK-NOT: baseType: 31 // CHECK-SAME: size: 32, align: 32 32 // CHECK-NOT: offset: 33 // CHECK-NOT: flags: 34 // CHECK-SAME: ){{$}} 35 36 namespace PR14029 { 37 // Make sure this doesn't crash/assert. 38 template <typename T> struct Test { 39 enum class Tag { 40 test = 0 41 }; 42 Test() { 43 auto t = Tag::test; 44 } 45 Tag tag() const { return static_cast<Tag>(1); } 46 }; 47 Test<int> t; 48 } 49 50 namespace test2 { 51 // FIXME: this should just be a declaration under -fno-standalone-debug 52 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "E" 53 // CHECK-SAME: scope: [[TEST2:![0-9]+]] 54 // CHECK-SAME: elements: [[TEST_ENUMS:![0-9]+]] 55 // CHECK-SAME: identifier: "_ZTSN5test21EE" 56 // CHECK: [[TEST2]] = !MDNamespace(name: "test2" 57 // CHECK: [[TEST_ENUMS]] = !{[[TEST_E:![0-9]*]]} 58 // CHECK: [[TEST_E]] = !MDEnumerator(name: "e", value: 0) 59 enum E : int; 60 void func(E *) { 61 } 62 enum E : int { e }; 63 } 64 65 namespace test3 { 66 // FIXME: this should just be a declaration under -fno-standalone-debug 67 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "E" 68 // CHECK-SAME: scope: [[TEST3:![0-9]+]] 69 // CHECK-SAME: elements: [[TEST_ENUMS]] 70 // CHECK-SAME: identifier: "_ZTSN5test31EE" 71 // CHECK: [[TEST3]] = !MDNamespace(name: "test3" 72 enum E : int { e }; 73 void func(E *) { 74 } 75 } 76 77 namespace test4 { 78 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "E" 79 // CHECK-SAME: scope: [[TEST4:![0-9]+]] 80 // CHECK-SAME: elements: [[TEST_ENUMS]] 81 // CHECK-SAME: identifier: "_ZTSN5test41EE" 82 // CHECK: [[TEST4]] = !MDNamespace(name: "test4" 83 enum E : int; 84 void f1(E *) { 85 } 86 enum E : int { e }; 87 void f2(E) { 88 } 89 } 90 91 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "D" 92 // CHECK-SAME: line: 6 93 // CHECK-SAME: size: 16, align: 16 94 // CHECK-NOT: offset: 95 // CHECK-SAME: flags: DIFlagFwdDecl 96 97 namespace test5 { 98 // CHECK: !MDCompositeType(tag: DW_TAG_enumeration_type, name: "E" 99 // CHECK-SAME: scope: [[TEST5:![0-9]+]] 100 // CHECK-SAME: flags: DIFlagFwdDecl 101 // CHECK-SAME: identifier: "_ZTSN5test51EE" 102 // CHECK: [[TEST5]] = !MDNamespace(name: "test5" 103 enum E : int; 104 void f1(E *) { 105 } 106 } 107 108 namespace test6 { 109 // Ensure typedef'd enums aren't manifest by debug info generation. 110 // This could cause "typedef changes linkage of anonymous type, but linkage was 111 // already computed" errors. 112 // CHECK-NOT: test6 113 typedef enum { 114 } E; 115 } 116