Fix #77035.
[mono.git] / mcs / mcs / cs-tokenizer.cs
index 607c9b44dad692839b2b643883600491e9822b6b..83b92d2f9aa6dd9bab28880a8ea3aa241784e65e 100644 (file)
@@ -1595,13 +1595,6 @@ namespace Mono.CSharp
                // 
                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
@@ -1611,7 +1604,6 @@ namespace Mono.CSharp
                {
                        string cmd, arg;
                        bool region_directive = false;
-                       current_location = new Location (ref_line, Col);
 
                        get_cmd_arg (out cmd, out arg);
 
@@ -1632,22 +1624,12 @@ namespace Mono.CSharp
 
                                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 "undef":
-                               if (any_token_seen){
-                                       Error_TokensSeen ();
-                                       return caller_is_taking;
-                               }
-                               if (caller_is_taking)
-                                       PreProcessDefinition (false, arg);
+                       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 "region":
@@ -1780,14 +1762,6 @@ namespace Mono.CSharp
                                        
                                        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;
                        }
 
                        //
@@ -1797,12 +1771,21 @@ namespace Mono.CSharp
                                return false;
                                        
                        switch (cmd){
-                       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 "define":
+                               if (any_token_seen){
+                                       Error_TokensSeen ();
+                                       return true;
+                               }
+                               PreProcessDefinition (true, arg);
+                               return true;
+
+                       case "undef":
+                               if (any_token_seen){
+                                       Error_TokensSeen ();
+                                       return true;
+                               }
+                               PreProcessDefinition (false, arg);
+                               return true;
 
                        case "error":
                                Report.Error (1029, Location, "#error: '" + arg + "'");
@@ -1812,7 +1795,10 @@ namespace Mono.CSharp
                                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)