blob: 2e79e66f49bd7636f2e0a1a9303e0c5c4ee70cad [file] [log] [blame]
Fariborz Jahanian379b2812012-07-17 18:00:08 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum %s
2// rdar://11824807
3
4typedef enum CCTestEnum
5{
6 One,
7 Two=4,
8 Three
9} CCTestEnum;
10
11CCTestEnum test = 50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
12CCTestEnum test1 = -50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
13
14CCTestEnum foo(CCTestEnum r) {
15 return 20; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
16}
17
18enum Test2 { K_zero, K_one };
19enum 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
24int main() {
25 CCTestEnum test = 1; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
26 test = 600; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
27 foo(2); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
28 foo(-1); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
29 foo(4);
30 foo(Two+1);
31}
32