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