2008-09-17 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / expression.cs
index 8e48c349e02bcd66cf4991e328c58056bbeca879..b3a88cccca53b401678513fbbfe2904bc8d030a2 100644 (file)
@@ -1143,12 +1143,6 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return null;
 
-                       if (probe_type_expr.Type == TypeManager.void_type) {
-                               // TODO: Void is missing location (ProbeType.Location)
-                               Error_VoidInvalidInTheContext (Location);
-                               return null;
-                       }
-
                        if ((probe_type_expr.Type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
                                Report.Error (-244, loc, "The `{0}' operator cannot be applied to an operand of a static type",
                                        OperatorName);
@@ -1471,9 +1465,6 @@ namespace Mono.CSharp {
                        this.target_type = cast_type;
                        this.expr = expr;
                        this.loc = loc;
-
-                       if (target_type == TypeManager.system_void_expr)
-                               Error_VoidInvalidInTheContext (loc);
                }
 
                public Expression TargetType {
@@ -1566,11 +1557,13 @@ namespace Mono.CSharp {
 
                        type = texpr.Type;
 
-                       if (type == TypeManager.void_type) {
-                               Error_VoidInvalidInTheContext (loc);
-                               return null;
+                       if ((type.Attributes & Class.StaticClassAttribute) == Class.StaticClassAttribute) {
+                               Report.Error (-244, loc, "The `default value' operator cannot be applied to an operand of a static type");
                        }
 
+                       if (type.IsPointer)
+                               return new NullLiteral (Location).ConvertImplicitly (type);
+
                        if (TypeManager.IsReferenceType (type)) {
                                return new EmptyConstantCast (new NullLiteral (Location), type);
 
@@ -5409,11 +5402,6 @@ namespace Mono.CSharp {
 
                        type = texpr.Type;
 
-                       if (type == TypeManager.void_type) {
-                               Error_VoidInvalidInTheContext (loc);
-                               return null;
-                       }
-
                        if (type.IsPointer) {
                                Report.Error (1919, loc, "Unsafe type `{0}' cannot be used in an object creation expression",
                                        TypeManager.CSharpName (type));
@@ -5993,6 +5981,11 @@ namespace Mono.CSharp {
                                Report.Error (622, loc, "Can only use array initializer expressions to assign to array types. Try using a new expression instead");
                                return false;
                        }
+
+                       if (requested_base_type is VarExpr) {
+                               Report.Error (820, loc, "An implicitly typed local variable declarator cannot use an array initializer");
+                               return false;
+                       }
                        
                        StringBuilder array_qualifier = new StringBuilder (rank);
 
@@ -7208,11 +7201,6 @@ namespace Mono.CSharp {
                        if (TypeManager.IsEnumType (type_queried))
                                type_queried = TypeManager.GetEnumUnderlyingType (type_queried);
 
-                       if (type_queried == TypeManager.void_type) {
-                               Expression.Error_VoidInvalidInTheContext (loc);
-                               return null;
-                       }
-
                        int size_of = GetTypeSize (type_queried);
                        if (size_of > 0) {
                                return new IntConstant (size_of, loc);
@@ -8963,11 +8951,6 @@ namespace Mono.CSharp {
                                return null;
 
                        Type ltype = lexpr.Type;
-                       if ((ltype == TypeManager.void_type) && (dim != "*")) {
-                               Error_VoidInvalidInTheContext (loc);
-                               return null;
-                       }
-
 #if GMCS_SOURCE
                        if ((dim.Length > 0) && (dim [0] == '?')) {
                                TypeExpr nullable = new Nullable.NullableType (left, loc);
@@ -8981,7 +8964,7 @@ namespace Mono.CSharp {
                                return null;
 
                        if (dim.Length != 0 && dim [0] == '[') {
-                               if (ltype == TypeManager.arg_iterator_type || ltype == TypeManager.typed_reference_type) {
+                               if (TypeManager.IsSpecialType (ltype)) {
                                        Report.Error (611, loc, "Array elements cannot be of type `{0}'", TypeManager.CSharpName (ltype));
                                        return null;
                                }