blob: f0b97ccd2c8e17bb0e311853f120fe45fb649e03 [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
David Blaikie09a56042013-06-21 03:41:46 +000012// CHECK: ; [ DW_TAG_enumeration_type ] [A] [line 3, size 32, align 32, offset 0] [def] [from int]
13// CHECK: ; [ DW_TAG_enumeration_type ] [B] [line 4, size 64, align 64, offset 0] [def] [from long unsigned int]
14// CHECK: ; [ DW_TAG_enumeration_type ] [C] [line 5, size 32, align 32, offset 0] [def] [from ]
Eli Friedmane6b39bc2012-10-05 01:49:33 +000015
16namespace PR14029 {
17 // Make sure this doesn't crash/assert.
18 template <typename T> struct Test {
19 enum class Tag {
20 test = 0
21 };
22 Test() {
23 auto t = Tag::test;
24 }
25 Tag tag() const { return static_cast<Tag>(1); }
26 };
27 Test<int> t;
28}
Stephen Hines6bcf27b2014-05-29 04:14:42 -070029
30namespace test2 {
31// FIXME: this should just be a declaration under -fno-standalone-debug
32// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST2:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS:![0-9]*]], {{[^,]*}}, null, null, metadata !"_ZTSN5test21EE"} ; [ DW_TAG_enumeration_type ] [E]
33// CHECK: [[TEST2]] = {{.*}} ; [ DW_TAG_namespace ] [test2]
34// CHECK: [[TEST_ENUMS]] = metadata !{metadata [[TEST_E:![0-9]*]]}
35// CHECK: [[TEST_E]] = {{.*}}, metadata !"e", i64 0} ; [ DW_TAG_enumerator ] [e :: 0]
36enum E : int;
37void func(E *) {
38}
39enum E : int { e };
40}
41
42namespace test3 {
43// FIXME: this should just be a declaration under -fno-standalone-debug
44// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST3:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test31EE"} ; [ DW_TAG_enumeration_type ] [E]
45// CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3]
46enum E : int { e };
47void func(E *) {
48}
49}
50
51namespace test4 {
52// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST4:![0-9]*]], {{.*}}, metadata [[TEST_ENUMS]], {{[^,]*}}, null, null, metadata !"_ZTSN5test41EE"} ; [ DW_TAG_enumeration_type ] [E]
53// CHECK: [[TEST4]] = {{.*}} ; [ DW_TAG_namespace ] [test4]
54enum E : int;
55void f1(E *) {
56}
57enum E : int { e };
58void f2(E) {
59}
60}
61
62// CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [decl] [from ]
63
64namespace test5 {
65// CHECK: metadata !{i32 {{[^,]*}}, {{[^,]*}}, metadata [[TEST5:![0-9]*]], {{.*}}, null, {{[^,]*}}, null, null, metadata !"_ZTSN5test51EE"} ; [ DW_TAG_enumeration_type ] [E]
66// CHECK: [[TEST5]] = {{.*}} ; [ DW_TAG_namespace ] [test5]
67enum E : int;
68void f1(E *) {
69}
70}
71
72namespace test6 {
73// Ensure typedef'd enums aren't manifest by debug info generation.
74// This could cause "typedef changes linkage of anonymous type, but linkage was
75// already computed" errors.
76// CHECK-NOT: test7
77typedef enum {
78} E;
79}