xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/debug-info-enum-class.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc enum class A { A1=1 };                 // underlying type is int by default
4f4a2713aSLionel Sambuc enum class B: unsigned long { B1=1 };  // underlying type is unsigned long
5f4a2713aSLionel Sambuc enum C { C1 = 1 };
6f4a2713aSLionel Sambuc enum D : short; // enum forward declaration
7f4a2713aSLionel Sambuc A a;
8f4a2713aSLionel Sambuc B b;
9f4a2713aSLionel Sambuc C c;
10f4a2713aSLionel Sambuc D d;
11f4a2713aSLionel Sambuc 
12f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_enumeration_type ] [A] [line 3, size 32, align 32, offset 0] [def] [from int]
13f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_enumeration_type ] [B] [line 4, size 64, align 64, offset 0] [def] [from long unsigned int]
14f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_enumeration_type ] [C] [line 5, size 32, align 32, offset 0] [def] [from ]
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc namespace PR14029 {
17f4a2713aSLionel Sambuc   // Make sure this doesn't crash/assert.
18f4a2713aSLionel Sambuc   template <typename T> struct Test {
19f4a2713aSLionel Sambuc     enum class Tag {
20f4a2713aSLionel Sambuc       test = 0
21f4a2713aSLionel Sambuc     };
TestPR14029::Test22f4a2713aSLionel Sambuc     Test() {
23f4a2713aSLionel Sambuc       auto t = Tag::test;
24f4a2713aSLionel Sambuc     }
tagPR14029::Test25f4a2713aSLionel Sambuc     Tag tag() const { return static_cast<Tag>(1); }
26f4a2713aSLionel Sambuc   };
27f4a2713aSLionel Sambuc   Test<int> t;
28f4a2713aSLionel Sambuc }
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc namespace test2 {
31*0a6a1f1dSLionel Sambuc // FIXME: this should just be a declaration under -fno-standalone-debug
32*0a6a1f1dSLionel Sambuc // CHECK:  !"0x4\00{{.*}}", {{[^,]*}}, [[TEST2:![0-9]*]], {{.*}}, [[TEST_ENUMS:![0-9]*]], null, null, !"_ZTSN5test21EE"} ; [ DW_TAG_enumeration_type ] [E]
33*0a6a1f1dSLionel Sambuc // CHECK: [[TEST2]] = {{.*}} ; [ DW_TAG_namespace ] [test2]
34*0a6a1f1dSLionel Sambuc // CHECK: [[TEST_ENUMS]] = !{[[TEST_E:![0-9]*]]}
35*0a6a1f1dSLionel Sambuc // CHECK: [[TEST_E]] = !{!"0x28\00e\000"} ; [ DW_TAG_enumerator ] [e :: 0]
36*0a6a1f1dSLionel Sambuc enum E : int;
func(E *)37*0a6a1f1dSLionel Sambuc void func(E *) {
38*0a6a1f1dSLionel Sambuc }
39*0a6a1f1dSLionel Sambuc enum E : int { e };
40*0a6a1f1dSLionel Sambuc }
41*0a6a1f1dSLionel Sambuc 
42*0a6a1f1dSLionel Sambuc namespace test3 {
43*0a6a1f1dSLionel Sambuc // FIXME: this should just be a declaration under -fno-standalone-debug
44*0a6a1f1dSLionel Sambuc // CHECK:  !"0x4\00{{.*}}", {{[^,]*}}, [[TEST3:![0-9]*]], {{.*}}, [[TEST_ENUMS]], null, null, !"_ZTSN5test31EE"} ; [ DW_TAG_enumeration_type ] [E]
45*0a6a1f1dSLionel Sambuc // CHECK: [[TEST3]] = {{.*}} ; [ DW_TAG_namespace ] [test3]
46*0a6a1f1dSLionel Sambuc enum E : int { e };
func(E *)47*0a6a1f1dSLionel Sambuc void func(E *) {
48*0a6a1f1dSLionel Sambuc }
49*0a6a1f1dSLionel Sambuc }
50*0a6a1f1dSLionel Sambuc 
51*0a6a1f1dSLionel Sambuc namespace test4 {
52*0a6a1f1dSLionel Sambuc // CHECK:  !"0x4\00{{.*}}", {{[^,]*}}, [[TEST4:![0-9]*]], {{.*}}, [[TEST_ENUMS]], null, null, !"_ZTSN5test41EE"} ; [ DW_TAG_enumeration_type ] [E]
53*0a6a1f1dSLionel Sambuc // CHECK: [[TEST4]] = {{.*}} ; [ DW_TAG_namespace ] [test4]
54*0a6a1f1dSLionel Sambuc enum E : int;
f1(E *)55*0a6a1f1dSLionel Sambuc void f1(E *) {
56*0a6a1f1dSLionel Sambuc }
57*0a6a1f1dSLionel Sambuc enum E : int { e };
f2(E)58*0a6a1f1dSLionel Sambuc void f2(E) {
59*0a6a1f1dSLionel Sambuc }
60*0a6a1f1dSLionel Sambuc }
61*0a6a1f1dSLionel Sambuc 
62*0a6a1f1dSLionel Sambuc // CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [decl] [from ]
63*0a6a1f1dSLionel Sambuc 
64*0a6a1f1dSLionel Sambuc namespace test5 {
65*0a6a1f1dSLionel Sambuc // CHECK:  !"0x4\00{{.*}}", {{[^,]*}}, [[TEST5:![0-9]*]], {{.*}}, null, null, null, !"_ZTSN5test51EE"} ; [ DW_TAG_enumeration_type ] [E]
66*0a6a1f1dSLionel Sambuc // CHECK: [[TEST5]] = {{.*}} ; [ DW_TAG_namespace ] [test5]
67*0a6a1f1dSLionel Sambuc enum E : int;
f1(E *)68*0a6a1f1dSLionel Sambuc void f1(E *) {
69*0a6a1f1dSLionel Sambuc }
70*0a6a1f1dSLionel Sambuc }
71*0a6a1f1dSLionel Sambuc 
72*0a6a1f1dSLionel Sambuc namespace test6 {
73*0a6a1f1dSLionel Sambuc // Ensure typedef'd enums aren't manifest by debug info generation.
74*0a6a1f1dSLionel Sambuc // This could cause "typedef changes linkage of anonymous type, but linkage was
75*0a6a1f1dSLionel Sambuc // already computed" errors.
76*0a6a1f1dSLionel Sambuc // CHECK-NOT: test7
77*0a6a1f1dSLionel Sambuc typedef enum {
78*0a6a1f1dSLionel Sambuc } E;
79*0a6a1f1dSLionel Sambuc }
80