unscoped_unspecified_tInvalidBeforeRangeBegin=static_cast<unscoped_unspecified_t>(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidNegativeValue1=static_cast<unscoped_unspecified_t>(-4);// OK.
unscoped_unspecified_tValidNegativeValue2=static_cast<unscoped_unspecified_t>(-3);// OK.
unscoped_unspecified_tInvalidInsideRange1=static_cast<unscoped_unspecified_t>(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tInvalidInsideRange2=static_cast<unscoped_unspecified_t>(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tInvalidInsideRange3=static_cast<unscoped_unspecified_t>(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidPositiveValue1=static_cast<unscoped_unspecified_t>(1);// OK.
unscoped_unspecified_tValidPositiveValue2=static_cast<unscoped_unspecified_t>(2);// OK.
unscoped_unspecified_tInvalidInsideRange4=static_cast<unscoped_unspecified_t>(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidPositiveValue3=static_cast<unscoped_unspecified_t>(4);// OK.
unscoped_unspecified_tInvalidAfterRangeEnd=static_cast<unscoped_unspecified_t>(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidunscopedSpecified(){
unscoped_specified_tInvalidBeforeRangeBegin=static_cast<unscoped_specified_t>(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidNegativeValue1=static_cast<unscoped_specified_t>(-4);// OK.
unscoped_specified_tValidNegativeValue2=static_cast<unscoped_specified_t>(-3);// OK.
unscoped_specified_tInvalidInsideRange1=static_cast<unscoped_specified_t>(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tInvalidInsideRange2=static_cast<unscoped_specified_t>(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tInvalidInsideRange3=static_cast<unscoped_specified_t>(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidPositiveValue1=static_cast<unscoped_specified_t>(1);// OK.
unscoped_specified_tValidPositiveValue2=static_cast<unscoped_specified_t>(2);// OK.
unscoped_specified_tInvalidInsideRange4=static_cast<unscoped_specified_t>(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidPositiveValue3=static_cast<unscoped_specified_t>(4);// OK.
unscoped_specified_tInvalidAfterRangeEnd=static_cast<unscoped_specified_t>(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidscopedUnspecified(){
scoped_unspecified_tInvalidBeforeRangeBegin=static_cast<scoped_unspecified_t>(-5);// expected-warning{{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidNegativeValue1=static_cast<scoped_unspecified_t>(-4);// OK.
scoped_unspecified_tValidNegativeValue2=static_cast<scoped_unspecified_t>(-3);// OK.
scoped_unspecified_tInvalidInsideRange1=static_cast<scoped_unspecified_t>(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tInvalidInsideRange2=static_cast<scoped_unspecified_t>(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tInvalidInsideRange3=static_cast<scoped_unspecified_t>(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidPositiveValue1=static_cast<scoped_unspecified_t>(1);// OK.
scoped_unspecified_tValidPositiveValue2=static_cast<scoped_unspecified_t>(2);// OK.
scoped_unspecified_tInvalidInsideRange4=static_cast<scoped_unspecified_t>(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidPositiveValue3=static_cast<scoped_unspecified_t>(4);// OK.
scoped_unspecified_tInvalidAfterRangeEnd=static_cast<scoped_unspecified_t>(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidscopedSpecified(){
scoped_specified_tInvalidBeforeRangeBegin=static_cast<scoped_specified_t>(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidNegativeValue1=static_cast<scoped_specified_t>(-4);// OK.
scoped_specified_tValidNegativeValue2=static_cast<scoped_specified_t>(-3);// OK.
scoped_specified_tInvalidInsideRange1=static_cast<scoped_specified_t>(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tInvalidInsideRange2=static_cast<scoped_specified_t>(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tInvalidInsideRange3=static_cast<scoped_specified_t>(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidPositiveValue1=static_cast<scoped_specified_t>(1);// OK.
scoped_specified_tValidPositiveValue2=static_cast<scoped_specified_t>(2);// OK.
scoped_specified_tInvalidInsideRange4=static_cast<scoped_specified_t>(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidPositiveValue3=static_cast<scoped_specified_t>(4);// OK.
scoped_specified_tInvalidAfterRangeEnd=static_cast<scoped_specified_t>(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidunscopedUnspecifiedCStyle(){
unscoped_unspecified_tInvalidBeforeRangeBegin=(unscoped_unspecified_t)(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidNegativeValue1=(unscoped_unspecified_t)(-4);// OK.
unscoped_unspecified_tValidNegativeValue2=(unscoped_unspecified_t)(-3);// OK.
unscoped_unspecified_tInvalidInsideRange1=(unscoped_unspecified_t)(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tInvalidInsideRange2=(unscoped_unspecified_t)(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tInvalidInsideRange3=(unscoped_unspecified_t)(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidPositiveValue1=(unscoped_unspecified_t)(1);// OK.
unscoped_unspecified_tValidPositiveValue2=(unscoped_unspecified_t)(2);// OK.
unscoped_unspecified_tInvalidInsideRange4=(unscoped_unspecified_t)(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_unspecified_tValidPositiveValue3=(unscoped_unspecified_t)(4);// OK.
unscoped_unspecified_tInvalidAfterRangeEnd=(unscoped_unspecified_t)(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidunscopedSpecifiedCStyle(){
unscoped_specified_tInvalidBeforeRangeBegin=(unscoped_specified_t)(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidNegativeValue1=(unscoped_specified_t)(-4);// OK.
unscoped_specified_tValidNegativeValue2=(unscoped_specified_t)(-3);// OK.
unscoped_specified_tInvalidInsideRange1=(unscoped_specified_t)(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tInvalidInsideRange2=(unscoped_specified_t)(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tInvalidInsideRange3=(unscoped_specified_t)(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidPositiveValue1=(unscoped_specified_t)(1);// OK.
unscoped_specified_tValidPositiveValue2=(unscoped_specified_t)(2);// OK.
unscoped_specified_tInvalidInsideRange4=(unscoped_specified_t)(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
unscoped_specified_tValidPositiveValue3=(unscoped_specified_t)(4);// OK.
unscoped_specified_tInvalidAfterRangeEnd=(unscoped_specified_t)(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidscopedUnspecifiedCStyle(){
scoped_unspecified_tInvalidBeforeRangeBegin=(scoped_unspecified_t)(-5);// expected-warning{{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidNegativeValue1=(scoped_unspecified_t)(-4);// OK.
scoped_unspecified_tValidNegativeValue2=(scoped_unspecified_t)(-3);// OK.
scoped_unspecified_tInvalidInsideRange1=(scoped_unspecified_t)(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tInvalidInsideRange2=(scoped_unspecified_t)(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tInvalidInsideRange3=(scoped_unspecified_t)(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidPositiveValue1=(scoped_unspecified_t)(1);// OK.
scoped_unspecified_tValidPositiveValue2=(scoped_unspecified_t)(2);// OK.
scoped_unspecified_tInvalidInsideRange4=(scoped_unspecified_t)(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_unspecified_tValidPositiveValue3=(scoped_unspecified_t)(4);// OK.
scoped_unspecified_tInvalidAfterRangeEnd=(scoped_unspecified_t)(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidscopedSpecifiedCStyle(){
scoped_specified_tInvalidBeforeRangeBegin=(scoped_specified_t)(-5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidNegativeValue1=(scoped_specified_t)(-4);// OK.
scoped_specified_tValidNegativeValue2=(scoped_specified_t)(-3);// OK.
scoped_specified_tInvalidInsideRange1=(scoped_specified_t)(-2);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tInvalidInsideRange2=(scoped_specified_t)(-1);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tInvalidInsideRange3=(scoped_specified_t)(0);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidPositiveValue1=(scoped_specified_t)(1);// OK.
scoped_specified_tValidPositiveValue2=(scoped_specified_t)(2);// OK.
scoped_specified_tInvalidInsideRange4=(scoped_specified_t)(3);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
scoped_specified_tValidPositiveValue3=(scoped_specified_t)(4);// OK.
scoped_specified_tInvalidAfterRangeEnd=(scoped_specified_t)(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
autovalue=static_cast<scoped_specified_t>(input);// OK. Being conservative, this is a possibly good value.
}
voidrangeConstrained2(intinput){
if(input<-5)
autovalue=static_cast<scoped_specified_t>(input);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidrangeConstrained3(intinput){
if(input>=-2&&input<=-1)
autovalue=static_cast<scoped_specified_t>(input);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidrangeConstrained4(intinput){
if(input>=-2&&input<=1)
autovalue=static_cast<scoped_specified_t>(input);// OK. Possibly 1.
}
voidrangeConstrained5(intinput){
if(input>=1&&input<=2)
autovalue=static_cast<scoped_specified_t>(input);// OK. Strict inner matching.
}
voidrangeConstrained6(intinput){
if(input>=2&&input<=4)
autovalue=static_cast<scoped_specified_t>(input);// OK. The value is possibly 2 or 4, dont warn.
}
voidrangeConstrained7(intinput){
if(input>=3&&input<=3)
autovalue=static_cast<scoped_specified_t>(input);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}
}
voidenumBitFieldAssignment(){
Ss;
s.E=static_cast<unscoped_unspecified_t>(4);// OK.
s.E=static_cast<unscoped_unspecified_t>(5);// expected-warning {{The value provided to the cast expression is not in the valid range of values for the enum}}