1 // RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum %s
2 // rdar://11824807
3
4 typedef enum CCTestEnum
5 {
6 One,
7 Two=4,
8 Three
9 } CCTestEnum;
10
11 CCTestEnum test = 50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
12 CCTestEnum test1 = -50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
13
foo(CCTestEnum r)14 CCTestEnum foo(CCTestEnum r) {
15 return 20; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
16 }
17
18 enum Test2 { K_zero, K_one };
test2(enum Test2 * t)19 enum Test2 test2(enum Test2 *t) {
20 *t = 20; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}}
21 return 10; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}}
22 }
23
24 // PR15069
25 typedef enum
26 {
27 a = 0
28 } T;
29
f()30 void f()
31 {
32 T x = a;
33 x += 1; // expected-warning {{integer constant not in range of enumerated type}}
34 }
35
main()36 int main() {
37 CCTestEnum test = 1; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
38 test = 600; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
39 foo(2); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
40 foo(-1); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
41 foo(4);
42 foo(Two+1);
43 }
44
45