[mcs] Report less internal errors. Fixes #17472
authorMarek Safar <marek.safar@gmail.com>
Fri, 31 Jan 2014 10:44:04 +0000 (11:44 +0100)
committerMarek Safar <marek.safar@gmail.com>
Fri, 31 Jan 2014 10:44:04 +0000 (11:44 +0100)
mcs/errors/Makefile
mcs/errors/cs0117-8.cs [new file with mode: 0644]
mcs/mcs/convert.cs
mcs/mcs/ecore.cs
mcs/mcs/parameter.cs
mcs/mcs/settings.cs
mcs/mcs/statement.cs

index 6e50c17d37598699b11c666e71d98785397dd112..4cdfc248df5831694ae59e32730aacc5242a61e3 100644 (file)
@@ -60,7 +60,7 @@ run-test-local: clean-local
 # -compiler-options:-v
 
 TEST_PATTERN = 'v4'
-TESTER_OPTIONS = -compiler-options:"-v -d:NET_4_0;NET_4_5"
+TESTER_OPTIONS = -compiler-options:"-v --break-on-ice -d:NET_4_0;NET_4_5"
 
 COMPILER = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/mcs.exe
 TESTER = MONO_RUNTIME='$(RUNTIME)' $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(LOCAL_RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/compiler-tester.exe
diff --git a/mcs/errors/cs0117-8.cs b/mcs/errors/cs0117-8.cs
new file mode 100644 (file)
index 0000000..1e69f70
--- /dev/null
@@ -0,0 +1,14 @@
+// CS0117: `X' does not contain a definition for `P'
+// Line: 11
+
+class X
+{
+       public void Test ()
+       {
+               Foo ();
+       }
+
+       public static void Foo (string Product = X.P)
+       {
+       }
+}
\ No newline at end of file
index e2e1268f35656e952f8299d8324dd67928b35faa..5035226d5280fd9b44611401b151b48e85dee149 100644 (file)
@@ -1412,25 +1412,23 @@ namespace Mono.CSharp {
                                }
                        }
 
-                       if (ec.IsUnsafe) {
-                               var target_pc = target_type as PointerContainer;
-                               if (target_pc != null) {
-                                       if (expr_type.IsPointer) {
-                                               //
-                                               // Pointer types are same when they have same element types
-                                               //
-                                               if (expr_type == target_pc)
-                                                       return expr;
+                       var target_pc = target_type as PointerContainer;
+                       if (target_pc != null) {
+                               if (expr_type.IsPointer) {
+                                       //
+                                       // Pointer types are same when they have same element types
+                                       //
+                                       if (expr_type == target_pc)
+                                               return expr;
 
-                                               if (target_pc.Element.Kind == MemberKind.Void)
-                                                       return EmptyCast.Create (expr, target_type);
+                                       if (target_pc.Element.Kind == MemberKind.Void)
+                                               return EmptyCast.Create (expr, target_type);
 
                                                //return null;
-                                       }
-
-                                       if (expr_type == InternalType.NullLiteral)
-                                               return new NullPointer (target_type, loc);
                                }
+
+                               if (expr_type == InternalType.NullLiteral)
+                                       return new NullPointer (target_type, loc);
                        }
 
                        if (expr_type == InternalType.AnonymousMethod){
index e1162714ddc563b2df057d5ab17a17f64f893459..bc024ecd662873b7df78b7da93f284546316acdd 100644 (file)
@@ -466,7 +466,7 @@ namespace Mono.CSharp {
 
                                return e;
                        } catch (Exception ex) {
-                               if (loc.IsNull || ec.Module.Compiler.Settings.DebugFlags > 0 || ex is CompletionResult || ec.Report.IsDisabled || ex is FatalException ||
+                               if (loc.IsNull || ec.Module.Compiler.Settings.BreakOnInternalError || ex is CompletionResult || ec.Report.IsDisabled || ex is FatalException ||
                                        ec.Report.Printer is NullReportPrinter)
                                        throw;
 
@@ -4618,7 +4618,7 @@ namespace Mono.CSharp {
                        if (ms != null && ms.IsGeneric) {
                                if (type_arguments != null) {
                                        var g_args_count = ms.Arity;
-                                       if (g_args_count != type_arguments.Count)
+                                       if (g_args_count != type_arguments.Count || type_arguments.Arguments == null)
                                                return int.MaxValue - 20000 + System.Math.Abs (type_arguments.Count - g_args_count);
 
                                        ms = ms.MakeGenericMethod (ec, type_arguments.Arguments);
index 2929a690c2d2fbb82c98ab443c3f734da892fbec..da2b13e4ab69e7fd6949e65c4f065eced3f065e7 100644 (file)
@@ -1336,8 +1336,10 @@ namespace Mono.CSharp {
                public void Resolve (ResolveContext rc, Parameter p)
                {
                        var expr = Resolve (rc);
-                       if (expr == null)
+                       if (expr == null) {
+                               this.expr = ErrorExpression.Instance;
                                return;
+                       }
 
                        expr = Child;
 
index eaac5974126955f51533576127d8b57967e548bc..01c37873ecd60872cbc71cd8b3e707d17be34189 100644 (file)
@@ -146,6 +146,7 @@ namespace Mono.CSharp {
                public int VerboseParserFlag;
                public int FatalCounter;
                public bool Stacktrace;
+               public bool BreakOnInternalError;
                #endregion
 
                public bool ShowFullPaths;
@@ -669,7 +670,8 @@ namespace Mono.CSharp {
                                "   --stacktrace       Shows stack trace at error location\n" +
                                "   --timestamp        Displays time stamps of various compiler events\n" +
                                "   -v                 Verbose parsing (for debugging the parser)\n" +
-                               "   --mcs-debug X      Sets MCS debugging level to X\n");
+                               "   --mcs-debug X      Sets MCS debugging level to X\n" +
+                               "   --break-on-ice     Breaks compilation on internal compiler error");
                }
 
                //
@@ -1421,6 +1423,10 @@ namespace Mono.CSharp {
                                settings.WriteMetadataOnly = true;
                                return ParseResult.Success;
 
+                       case "--break-on-ice":
+                               settings.BreakOnInternalError = true;
+                               return ParseResult.Success;
+
                        default:
                                if (arg.StartsWith ("--fatal", StringComparison.Ordinal)){
                                        int fatal = 1;
index 160431030e0d1f7a06aa9197846e5123b6e63326..2bc9aed2c37c9a398c11dbbe5cdd7b4f4e14b4c2 100644 (file)
@@ -3798,7 +3798,7 @@ namespace Mono.CSharp {
                                        return false;
 
                        } catch (Exception e) {
-                               if (e is CompletionResult || bc.Report.IsDisabled || e is FatalException || bc.Report.Printer is NullReportPrinter)
+                               if (e is CompletionResult || bc.Report.IsDisabled || e is FatalException || bc.Report.Printer is NullReportPrinter || bc.Module.Compiler.Settings.BreakOnInternalError)
                                        throw;
 
                                if (bc.CurrentBlock != null) {
@@ -3806,9 +3806,6 @@ namespace Mono.CSharp {
                                } else {
                                        bc.Report.Error (587, "Internal compiler error: {0}", e.Message);
                                }
-
-                               if (bc.Module.Compiler.Settings.DebugFlags > 0)
-                                       throw;
                        }
 
                        //