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 | |
David Blaikie | 09a5604 | 2013-06-21 03:41:46 +0000 | [diff] [blame] | 12 | // 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 Friedman | e6b39bc | 2012-10-05 01:49:33 +0000 | [diff] [blame] | 15 | |
| 16 | namespace 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 Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame] | 29 | |
| 30 | namespace 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] |
| 36 | enum E : int; |
| 37 | void func(E *) { |
| 38 | } |
| 39 | enum E : int { e }; |
| 40 | } |
| 41 | |
| 42 | namespace 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] |
| 46 | enum E : int { e }; |
| 47 | void func(E *) { |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | namespace 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] |
| 54 | enum E : int; |
| 55 | void f1(E *) { |
| 56 | } |
| 57 | enum E : int { e }; |
| 58 | void f2(E) { |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // CHECK: ; [ DW_TAG_enumeration_type ] [D] [line 6, size 16, align 16, offset 0] [decl] [from ] |
| 63 | |
| 64 | namespace 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] |
| 67 | enum E : int; |
| 68 | void f1(E *) { |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | namespace 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 |
| 77 | typedef enum { |
| 78 | } E; |
| 79 | } |