+++ /dev/null
-// CS1008: Type byte, sbyte, short, ushort, int, uint, long or ulong expected
-// Line: 3
-enum Test : System.Int16
-{
- One
-}
-
-class X
-{
- static void Main ()
- { }
-}
-
-
if (expr is EnumConstant)
expr = ((EnumConstant) expr).Child;
- var underlying = ((Enum) Parent).UnderlyingType;
+ var en = (Enum)Parent;
+ var underlying = en.UnderlyingType;
if (expr != null) {
expr = expr.ImplicitConversionRequired (rc, underlying);
if (expr != null && !IsValidEnumType (expr.Type)) {
- Enum.Error_1008 (Location, Report);
+ en.Error_UnderlyingType (Location);
expr = null;
}
}
AddMember (em);
}
- public static void Error_1008 (Location loc, Report Report)
+ public void Error_UnderlyingType (Location loc)
{
Report.Error (1008, loc,
"Type byte, sbyte, short, ushort, int, uint, long or ulong expected");
protected override void DoDefineContainer ()
{
- ((EnumSpec) spec).UnderlyingType = underlying_type_expr == null ? Compiler.BuiltinTypes.Int : underlying_type_expr.Type;
+ TypeSpec ut;
+ if (underlying_type_expr != null) {
+ ut = underlying_type_expr.ResolveAsType (this);
+ if (!EnumSpec.IsValidUnderlyingType (ut)) {
+ Error_UnderlyingType (underlying_type_expr.Location);
+ ut = null;
+ }
+ } else {
+ ut = null;
+ }
+
+ if (ut == null)
+ ut = Compiler.BuiltinTypes.Int;
+
+ ((EnumSpec) spec).UnderlyingType = ut;
TypeBuilder.DefineField (UnderlyingValueField, UnderlyingType.GetMetaInfo (),
FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName);
</method>\r
</type>\r
</test>\r
+ <test name="test-905.cs">\r
+ <type name="X">\r
+ <method name="Void Main()" attrs="150">\r
+ <size>2</size>\r
+ </method>\r
+ <method name="Void .ctor()" attrs="6278">\r
+ <size>7</size>\r
+ </method>\r
+ </type>\r
+ </test>\r
<test name="test-91.cs">\r
<type name="Abstract">\r
<method name="Void .ctor()" attrs="6276">\r