2006-08-13 Marek Safar <marek.safar@seznam.cz>
authorMarek Safar <marek.safar@gmail.com>
Sun, 13 Aug 2006 13:50:20 +0000 (13:50 -0000)
committerMarek Safar <marek.safar@gmail.com>
Sun, 13 Aug 2006 13:50:20 +0000 (13:50 -0000)
A fix for #79056
* cs-parser.jay: Don't destroy current array type by typeof of array's.

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

mcs/gmcs/ChangeLog
mcs/gmcs/cs-parser.jay
mcs/mcs/ChangeLog
mcs/mcs/cs-parser.jay
mcs/tests/test-528.cs [new file with mode: 0644]

index 273c9c16e2fe52385de9b897add2d5df35d8246e..e9c59407a670067f1e7ba9682f65d134cb795d10 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-13  Marek Safar  <marek.safar@seznam.cz>
+
+       A fix for #79056
+       * cs-parser.jay: Don't destroy current array type by typeof of array's.
+
 2006-08-12  Marek Safar  <marek.safar@seznam.cz>
 
        * cs-parser.jay: Check whether a constraint clause has already been
index c97fa6e1562f65cf39c4f499bb84dc1d6c289621..c07700c4ec0ea47726a17db1aa2a960eb870ab26 100644 (file)
@@ -63,6 +63,7 @@ namespace Mono.CSharp
                ///   Hack to help create non-typed array initializer
                /// </summary>
                public static Expression current_array_type;
+               Expression pushed_current_array_type;
 
                /// <summary>
                ///   Used to determine if we are parsing the get/set pair
@@ -3318,34 +3319,21 @@ variable_initializer_list
          }
        ;
 
-void_pointer_expression
-       : void_pointer_expression STAR
-         {
-               $$ = new ComposedCast ((Expression) $1, "*", lexer.Location);
-         }
-       | VOID STAR
-         {
-               $$ = new ComposedCast (TypeManager.system_void_expr, "*", lexer.Location);;
-         }
-       ;
-
 typeof_expression
-       : TYPEOF OPEN_PARENS VOID CLOSE_PARENS
-         {
-               $$ = new TypeOfVoid ((Location) $1);
-         }
-       | TYPEOF OPEN_PARENS void_pointer_expression CLOSE_PARENS
-         {
-               $$ = new TypeOf ((Expression) $3, (Location) $1);
+       : TYPEOF
+      {
+               pushed_current_array_type = current_array_type;
+               lexer.TypeOfParsing = true;
          }
-       | TYPEOF OPEN_PARENS
+         OPEN_PARENS type CLOSE_PARENS
          {
-               lexer.TypeOfParsing = true;
-         }
-         type CLOSE_PARENS
-         {
-               lexer.TypeOfParsing = false;
-               $$ = new TypeOf ((Expression) $4, lexer.Location);
+               lexer.TypeOfParsing = false;
+               Expression type = (Expression)$4;
+               if (type == TypeManager.system_void_expr)
+                       $$ = new TypeOfVoid ((Location) $1);
+               else
+                       $$ = new TypeOf (type, (Location) $1);
+               current_array_type = pushed_current_array_type;
          }
        ;
 
index 53812e7623583a1f329aaa22e3554fbb327d2dab..da0daf1a870ee634f1ab3ecc436bf17bf8d82911 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-13  Marek Safar  <marek.safar@seznam.cz>
+
+       A fix for #79056
+       * cs-parser.jay: Don't destroy current array type by typeof of array's.
+
 2006-08-12  Marek Safar  <marek.safar@seznam.cz>
 
        * class.cs (Method.Define): Issue a warning when generic method looks like
index 4614aab4d5169922112f2a2192d5ea494353a7b7..3c42f8633dfc07dd7a49e63b9a05d836b5cf45e9 100644 (file)
@@ -61,6 +61,7 @@ namespace Mono.CSharp
                ///   Hack to help create non-typed array initializer
                /// </summary>
                public static Expression current_array_type;
+               Expression pushed_current_array_type;
 
                /// <summary>
                ///   Used to determine if we are parsing the get/set pair
@@ -3064,13 +3065,18 @@ variable_initializer_list
        ;
 
 typeof_expression
-       : TYPEOF OPEN_PARENS VOID CLOSE_PARENS
-         {
-               $$ = new TypeOfVoid ((Location) $1);
+       : TYPEOF
+      {
+               pushed_current_array_type = current_array_type;
          }
-       | TYPEOF OPEN_PARENS type CLOSE_PARENS
+         OPEN_PARENS type CLOSE_PARENS
          {
-               $$ = new TypeOf ((Expression) $3, (Location) $1);
+               Expression type = (Expression)$4;
+               if (type == TypeManager.system_void_expr)
+                       $$ = new TypeOfVoid ((Location) $1);
+               else
+                       $$ = new TypeOf (type, (Location) $1);
+               current_array_type = pushed_current_array_type;
          }
        ;
 
diff --git a/mcs/tests/test-528.cs b/mcs/tests/test-528.cs
new file mode 100644 (file)
index 0000000..5ac87be
--- /dev/null
@@ -0,0 +1,13 @@
+using System;\r
+\r
+namespace MicroFocus.MONO.Bugs\r
+{\r
+       public class Odd\r
+       {\r
+               private static readonly Type[] _argTypes = { typeof(object[]) };\r
+\r
+               public static void Main()\r
+               {\r
+               }\r
+       }\r
+}
\ No newline at end of file