There are some lookup oddities with these as reported in PR45780, and
GCC doesn't support these behaviors at all. To be more consistent with
GCC and prevent the crashes caused by our lookup issues, nip the problem
in the bud and prohibit enums here.
return LHSType;
// ExtInt types aren't subject to conversions between them or normal integers,
- // so this fails.
+ // so this fails.
if(LHSType->isExtIntType() || RHSType->isExtIntType())
return QualType();
ScalarCast = CK_IntegralToFloating;
} else
return true;
- }
+ } else if (ScalarTy->isEnumeralType())
+ return true;
// Adjust scalar if desired.
if (Scalar) {
// When there is a vector and a scalar, conversions must be legal.
(void)(four_ints ? four_floats : 3); // should work, ints can convert to floats.
- (void)(four_ints ? four_uints : e); // should work, non-scoped enum can convert to uint.
+ (void)(four_ints ? four_uints : e); // expected-error {{cannot convert between scalar type 'E' and vector type 'FourUInts'}}
(void)(four_ints ? four_uints : se); // expected-error {{cannot convert between vector and non-scalar values ('FourUInts' (vector of 4 'unsigned int' values) and 'SE'}}
// GCC permits this, but our conversion rules reject this for truncation.
(void)(two_ints ? two_ints : us); // expected-error {{cannot convert between scalar type 'unsigned int' and vector type 'TwoInts'}}
second_type st;
}
}
+
+namespace PR45780 {
+enum E { Value = 15 };
+void use(char16 c) {
+ E e;
+ c &Value; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
+ c == Value; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
+ e | c; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
+ e != c; // expected-error{{cannot convert between scalar type 'PR45780::E' and vector type 'char16'}}
+}
+
+} // namespace PR45780