blob: 61b502e40d71a79e9fcc075a98887dfae07830db [file] [log] [blame]
Eric Christopher9ee5f462012-05-23 00:09:47 +00001// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s
2
3enum class A { A1=1 }; // underlying type is int by default
4enum class B: unsigned long { B1=1 }; // underlying type is unsigned long
5enum C { C1 = 1 };
Eric Christopher5a2eff82012-06-01 00:22:57 +00006enum D : short; // enum forward declaration
Eric Christopher9ee5f462012-05-23 00:09:47 +00007A a;
8B b;
9C c;
Eric Christopher5a2eff82012-06-01 00:22:57 +000010D d;
Eric Christopher9ee5f462012-05-23 00:09:47 +000011
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070012// 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 Friedmane6b39bc2012-10-05 01:49:33 +000035
36namespace 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 Hines6bcf27b2014-05-29 04:14:42 -070049
50namespace test2 {
51// FIXME: this should just be a declaration under -fno-standalone-debug
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070052// 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 Hines0e2c34f2015-03-23 12:09:02 -070057// CHECK: [[TEST_ENUMS]] = !{[[TEST_E:![0-9]*]]}
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070058// CHECK: [[TEST_E]] = !MDEnumerator(name: "e", value: 0)
Stephen Hines6bcf27b2014-05-29 04:14:42 -070059enum E : int;
60void func(E *) {
61}
62enum E : int { e };
63}
64
65namespace test3 {
66// FIXME: this should just be a declaration under -fno-standalone-debug
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070067// 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 Hines6bcf27b2014-05-29 04:14:42 -070072enum E : int { e };
73void func(E *) {
74}
75}
76
77namespace test4 {
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070078// 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 Hines6bcf27b2014-05-29 04:14:42 -070083enum E : int;
84void f1(E *) {
85}
86enum E : int { e };
87void f2(E) {
88}
89}
90
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070091// 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 Hines6bcf27b2014-05-29 04:14:42 -070096
97namespace test5 {
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070098// 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 Hines6bcf27b2014-05-29 04:14:42 -0700103enum E : int;
104void f1(E *) {
105}
106}
107
108namespace 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 Nainar3ea9e332015-04-08 08:57:32 -0700112// CHECK-NOT: test6
Stephen Hines6bcf27b2014-05-29 04:14:42 -0700113typedef enum {
114} E;
115}