Fariborz Jahanian | 379b281 | 2012-07-17 18:00:08 +0000 | [diff] [blame] | 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 | |
| 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 }; |
| 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 | int 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 | |