Author: atsushi
Date: 2005-12-09 05:24:45 -0500 (Fri, 09 Dec 2005)
New Revision: 54153

Added:
   trunk/mcs/tests/test-476.cs
Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/cs-tokenizer.cs
   trunk/mcs/tests/ChangeLog
   trunk/mcs/tests/known-issues-gmcs
   trunk/mcs/tests/test-60.cs
Log:
2005-12-09  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * cs-tokenizer.cs : fixed bug #75984:
          - #warning and #error should not be handled when the source line
            is disabled.
          - #line is not checked strictly when the source line is disabled.
          - #define and #undef is on the other hand checked strictly at any
            state.

        * test-476.cs : test for bug #75984.
        * test-60.cs : unrecognized directive should be handled as an error
          even in a disable line (the behavior has changed in 2.0).
        * known-issues-gmcs : added above cases.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/mcs/ChangeLog     2005-12-09 10:24:45 UTC (rev 54153)
@@ -1,3 +1,12 @@
+2005-12-09  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * cs-tokenizer.cs : fixed bug #75984:
+         - #warning and #error should not be handled when the source line
+           is disabled.
+         - #line is not checked strictly when the source line is disabled.
+         - #define and #undef is on the other hand checked strictly at any
+           state.
+
 2005-12-08  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * cs-tokenizer.cs : missing Location (actually, filename) in one of

Modified: trunk/mcs/mcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/mcs/cs-tokenizer.cs       2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/mcs/cs-tokenizer.cs       2005-12-09 10:24:45 UTC (rev 54153)
@@ -1595,6 +1595,13 @@
                // 
                bool process_directives = true;
 
+               // get current status of if blocks.
+               bool is_inside_disabled_block ()
+               {
+                       return ifstack != null && ifstack.Count != 0 &&
+                               ((int) ifstack.Peek ()) & TAKING == 0;
+               }
+
                //
                // if true, then the code continues processing the code
                // if false, the code stays in a loop until another directive is
@@ -1604,6 +1611,7 @@
                {
                        string cmd, arg;
                        bool region_directive = false;
+                       current_location = new Location (ref_line, Col);
 
                        get_cmd_arg (out cmd, out arg);
 
@@ -1624,12 +1632,22 @@
 
                                PreProcessPragma (arg);
                                return caller_is_taking;
+                       case "define":
+                               if (any_token_seen){
+                                       Error_TokensSeen ();
+                                       return true;
+                               }
+                               if (caller_is_taking)
+                                       PreProcessDefinition (true, arg);
+                               return true;
 
-                       case "line":
-                               if (!PreProcessLine (arg))
-                                       Report.Error (
-                                               1576, Location,
-                                               "The line number specified for 
#line directive is missing or invalid");
+                       case "undef":
+                               if (any_token_seen){
+                                       Error_TokensSeen ();
+                                       return caller_is_taking;
+                               }
+                               if (caller_is_taking)
+                                       PreProcessDefinition (false, arg);
                                return caller_is_taking;
 
                        case "region":
@@ -1762,6 +1780,14 @@
                                        
                                        return ret;
                                }
+                       case "line":
+                       case "error":
+                       case "warning":
+                               // processed only when current code block is 
not disabled.
+                               break; 
+                       default:
+                               Report.Error (1024, Location, "Wrong 
preprocessor directive");
+                               return caller_is_taking;
                        }
 
                        //
@@ -1771,22 +1797,13 @@
                                return false;
                                        
                        switch (cmd){
-                       case "define":
-                               if (any_token_seen){
-                                       Error_TokensSeen ();
-                                       return true;
-                               }
-                               PreProcessDefinition (true, arg);
-                               return true;
+                       case "line":
+                               if (!PreProcessLine (arg))
+                                       Report.Error (
+                                               1576, Location,
+                                               "The line number specified for 
#line directive is missing or invalid");
+                               return caller_is_taking;
 
-                       case "undef":
-                               if (any_token_seen){
-                                       Error_TokensSeen ();
-                                       return true;
-                               }
-                               PreProcessDefinition (false, arg);
-                               return true;
-
                        case "error":
                                Report.Error (1029, Location, "#error: '" + arg 
+ "'");
                                return true;
@@ -1795,10 +1812,7 @@
                                Report.Warning (1030, 1, Location, "#warning: 
`{0}'", arg);
                                return true;
                        }
-
-                       Report.Error (1024, Location, "Wrong preprocessor 
directive");
                        return true;
-
                }
 
                private int consume_string (bool quoted)

Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog   2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/tests/ChangeLog   2005-12-09 10:24:45 UTC (rev 54153)
@@ -1,3 +1,10 @@
+2005-12-09  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * test-476.cs : test for bug #75984.
+       * test-60.cs : unrecognized directive should be handled as an error
+         even in a disable line (the behavior has changed in 2.0).
+       * known-issues-gmcs : added above cases.
+
 2005-12-05  Marek Safar <[EMAIL PROTECTED]>
 
        * test-475.cs: Event initializer.

Modified: trunk/mcs/tests/known-issues-gmcs
===================================================================
--- trunk/mcs/tests/known-issues-gmcs   2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/tests/known-issues-gmcs   2005-12-09 10:24:45 UTC (rev 54153)
@@ -10,3 +10,5 @@
 test-anon-27.cs
 test-xml-027.cs
 test-465.cs IGNORE     # need to fix the path separator to work both on Unix 
and Windows
+test-60.cs
+tset-476.cs

Added: trunk/mcs/tests/test-476.cs
===================================================================
--- trunk/mcs/tests/test-476.cs 2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/tests/test-476.cs 2005-12-09 10:24:45 UTC (rev 54153)
@@ -0,0 +1,21 @@
+#if false
+#line hahaha
+#error
+#pragma warning disable 3005 // wrong directive on csc 1.x
+       public class Foo
+       {
+       }
+#pragma warning restore // wrong directive on csc 1.x
+
+#region // blank -> no error
+#endregion
+
+#endif // of funky directives
+
+public class Test
+{
+       public static void Main ()
+       {
+       }
+}
+


Property changes on: trunk/mcs/tests/test-476.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/mcs/tests/test-60.cs
===================================================================
--- trunk/mcs/tests/test-60.cs  2005-12-09 07:52:09 UTC (rev 54152)
+++ trunk/mcs/tests/test-60.cs  2005-12-09 10:24:45 UTC (rev 54153)
@@ -38,7 +38,7 @@
 #endif
 
 #if YY
-#errro this should not be printed
+//#errro this should not be printed // It used to compile under 1.x csc, but 
never under 2.x csc.
 #if X
 #elif Y
 #else

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to