blob: 3f005c9a6df7d998c4ec81695cd1a2b51f6f1d2a [file] [log] [blame]
Adrian Prantl70180702013-04-19 21:48:07 +00001// RUN: %clang_cc1 -triple armv7-apple-darwin10 -g -emit-llvm -o - %s | FileCheck %s
Adrian Prantl59d6a712013-04-19 19:56:39 +00002
3// The DWARF standard says the underlying data type of an enum may be
Adrian Prantl70180702013-04-19 21:48:07 +00004// stored in an DW_AT_type entry in the enum DIE. This is useful to have
5// so the debugger knows about the signedness of the underlying type.
Adrian Prantl59d6a712013-04-19 19:56:39 +00006
7typedef long NSInteger;
8#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
9
10// Enum with no specified underlying type
11typedef enum {
12 Enum0One,
13 Enum0Two
14} Enum0;
15
16// Enum declared with the NS_ENUM macro
17typedef NS_ENUM(NSInteger, Enum1) {
18 Enum1One = -1,
19 Enum1Two
20};
21
22// Enum declared with a fixed underlying type
23typedef enum : NSInteger {
24 Enum2One = -1,
25 Enum2Two
26} Enum2;
27
28// Typedef and declaration separately
29enum : NSInteger
30{
31 Enum3One = -1,
32 Enum3Two
33};
34typedef NSInteger Enum3;
35
36int main() {
37 Enum0 e0 = Enum0One;
38 // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM0:[0-9]+]])
39 Enum1 e1 = Enum1One;
40 // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM1:[0-9]+]])
41 Enum2 e2 = Enum2One;
42 // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM2:[0-9]+]])
43 Enum3 e3 = Enum3One;
44 // CHECK: call void @llvm.dbg.declare(metadata !{{.*}}, metadata ![[ENUM3:[0-9]+]])
45
46 // -Werror and the following line ensures that these enums are not
47 // -treated as C++11 strongly typed enums.
48 return e0 != e1 && e1 == e2 && e2 == e3;
49}
50// CHECK: ![[ENUMERATOR0:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 10
51// CHECK: ![[ENUMERATOR1:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [Enum1] [line 16{{.*}}] [from NSInteger]
52// CHECK: ![[ENUMERATOR3:[0-9]+]] = {{.*}}; [ DW_TAG_typedef ] [NSInteger] [line 6{{.*}}] [from long int]
53// CHECK: ![[ENUMERATOR2:[0-9]+]] = {{.*}}; [ DW_TAG_enumeration_type ] [line 22{{.*}}] [from NSInteger]
54
55// CHECK: ![[ENUM0]] = metadata !{{{.*}}!"e0", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE0:[0-9]+]]
56// CHECK: ![[TYPE0]] = metadata !{{{.*}}!"Enum0", {{.*}} metadata ![[ENUMERATOR0]]} ; [ DW_TAG_typedef ] [Enum0]
57
58// CHECK: ![[ENUM1]] = metadata !{{{.*}}!"e1", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE1:[0-9]+]]
59// CHECK: ![[TYPE1]] = metadata !{{{.*}}!"Enum1", {{.*}} metadata ![[ENUMERATOR1]]} ; [ DW_TAG_typedef ] [Enum1]
60
61// CHECK: ![[ENUM2]] = metadata !{{{.*}}!"e2", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE2:[0-9]+]]
62// CHECK: ![[TYPE2]] = metadata !{{{.*}}!"Enum2", {{.*}} metadata ![[ENUMERATOR2]]} ; [ DW_TAG_typedef ] [Enum2]
63
64// CHECK: ![[ENUM3]] = metadata !{{{.*}}!"e3", metadata !{{[0-9]+}}, i32 {{[0-9]+}}, metadata ![[TYPE3:[0-9]+]]
65// CHECK: ![[TYPE3]] = metadata !{{{.*}}!"Enum3", {{.*}} metadata ![[ENUMERATOR3]]} ; [ DW_TAG_typedef ] [Enum3]