Eric Christopher | 9ee5f46 | 2012-05-23 00:09:47 +0000 | [diff] [blame] | 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 }; |
Eric Christopher | 5a2eff8 | 2012-06-01 00:22:57 +0000 | [diff] [blame] | 6 | enum D : short; // enum forward declaration |
Eric Christopher | 9ee5f46 | 2012-05-23 00:09:47 +0000 | [diff] [blame] | 7 | A a; |
| 8 | B b; |
| 9 | C c; |
Eric Christopher | 5a2eff8 | 2012-06-01 00:22:57 +0000 | [diff] [blame] | 10 | D d; |
Eric Christopher | 9ee5f46 | 2012-05-23 00:09:47 +0000 | [diff] [blame] | 11 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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: ){{$}} |
Eli Friedman | e6b39bc | 2012-10-05 01:49:33 +0000 | [diff] [blame] | 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 | } |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 49 | |
| 50 | namespace test2 { |
| 51 | // FIXME: this should just be a declaration under -fno-standalone-debug |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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" |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 57 | // CHECK: [[TEST_ENUMS]] = !{[[TEST_E:![0-9]*]]} |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 58 | // CHECK: [[TEST_E]] = !MDEnumerator(name: "e", value: 0) |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 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 |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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" |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 72 | enum E : int { e }; |
| 73 | void func(E *) { |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | namespace test4 { |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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" |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 83 | enum E : int; |
| 84 | void f1(E *) { |
| 85 | } |
| 86 | enum E : int { e }; |
| 87 | void f2(E) { |
| 88 | } |
| 89 | } |
| 90 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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 |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 96 | |
| 97 | namespace test5 { |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 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" |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 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. |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 112 | // CHECK-NOT: test6 |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 113 | typedef enum { |
| 114 | } E; |
| 115 | } |