blob: 43eea0cef41fd8c31f7895957f92a3dc5cc96f91 [file] [log] [blame]
Fariborz Jahanian268fec12012-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
Joey Gouly1ba27332013-06-06 13:48:00 +000024// PR15069
25typedef enum
26{
27 a = 0
28} T;
29
30void f()
31{
32 T x = a;
33 x += 1; // expected-warning {{integer constant not in range of enumerated type}}
34}
35
Fariborz Jahanian268fec12012-07-17 18:00:08 +000036int 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