2010-04-12 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Mon, 12 Apr 2010 17:49:34 +0000 (17:49 -0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 12 Apr 2010 17:49:34 +0000 (17:49 -0000)
* expression.cs, attribute.cs: More attribute type checks.

svn path=/trunk/mcs/; revision=155256

mcs/mcs/ChangeLog
mcs/mcs/attribute.cs
mcs/mcs/expression.cs

index 2eddf55957c232ce4b98d6cf81db2ee6bcd58eb8..4d093b1bb9daee2a3c12bbd9c154c66f2953659e 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-12  Marek Safar  <marek.safar@gmail.com>
+
+       * expression.cs, attribute.cs: More attribute type checks.
+
 2010-04-12  Marek Safar  <marek.safar@gmail.com>
 
        A fix for bug #593342
index 1204e11b79037982270ba6820a823a08b3734348..a25f825654b06e4ae59108606ff93f76251a4b77 100644 (file)
@@ -1131,6 +1131,12 @@ namespace Mono.CSharp {
                        if (PosArguments != null) {
                                var param_types = TypeManager.GetParameterData (ctor).Types;
                                for (int j = 0; j < PosArguments.Count; ++j) {
+                                       var pt = param_types[j];
+                                       if (!IsValidArgumentType (pt)) {
+                                               Error_AttributeArgumentNotValid (context, loc);
+                                               return;
+                                       }
+
                                        var arg_expr = PosArguments[j].Expr;
                                        if (j == 0) {
                                                if (Type == predefined.IndexerName || Type == predefined.Conditional) {
@@ -1145,6 +1151,7 @@ namespace Mono.CSharp {
                                                                new Guid (v);
                                                        } catch (Exception e) {
                                                                Error_AttributeEmitError (e.Message);
+                                                               return;
                                                        }
                                                } else if (Type == predefined.AttributeUsage) {
                                                        int v = ((IntConstant)((EnumConstant) arg_expr).Child).Value;
@@ -1152,15 +1159,14 @@ namespace Mono.CSharp {
                                                                context.Compiler.Report.Error (591, Location, "Invalid value for argument to `{0}' attribute",
                                                                        "System.AttributeUsage");
                                                        }
-                                               }
-                                       } else if (j == 1) {
-                                               if (Type == predefined.MethodImpl && param_types[j] == TypeManager.short_type &&
-                                                       !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) PosArguments[0].Expr).GetTypedValue ())) {
+                                               } else if (Type == predefined.MethodImpl && pt == TypeManager.short_type &&
+                                                       !System.Enum.IsDefined (typeof (MethodImplOptions), ((Constant) arg_expr).GetValue ().ToString ())) {
                                                        Error_AttributeEmitError ("Incorrect argument value.");
+                                                       return;
                                                }
                                        }
 
-                                       arg_expr.EncodeAttributeValue (context, encoder, param_types[j]);
+                                       arg_expr.EncodeAttributeValue (context, encoder, pt);
                                }
                        }
 
index 548355dba01b598fe800a759ea3f033e7f527f5d..18a3062dd82df3bb4fc298d54c7047d9571deb83 100644 (file)
@@ -6465,8 +6465,8 @@ namespace Mono.CSharp {
 
                public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, Type targetType)
                {
-                       // no multi dimensional arrays
-                       if (arguments.Count != 1) {
+                       // no multi dimensional or jagged arrays
+                       if (arguments.Count != 1 || array_element_type.IsArray) {
                                base.EncodeAttributeValue (rc, enc, targetType);
                                return;
                        }