Author: raja
Date: 2006-05-18 07:02:03 -0400 (Thu, 18 May 2006)
New Revision: 60813
Added:
trunk/mcs/errors/cs0162-6.cs
trunk/mcs/errors/cs0162-7.cs
trunk/mcs/errors/cs0165-12.cs
trunk/mcs/tests/test-514.cs
trunk/mcs/tests/test-515.cs
trunk/mcs/tests/test-516.cs
trunk/mcs/tests/test-517.cs
Modified:
trunk/mcs/errors/ChangeLog
trunk/mcs/errors/known-issues-gmcs
trunk/mcs/errors/known-issues-mcs
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/flowanalysis.cs
trunk/mcs/gmcs/statement.cs
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/flowanalysis.cs
trunk/mcs/mcs/statement.cs
trunk/mcs/tests/ChangeLog
Log:
The 'piece de resistance' -- the culmination of the re-factoring effort :-)
In mcs:
Fix #77869, #76148, #77755, #75255 and a host of other bugs.
This is still "wrong", but anything better would probably need a
multi-pass algorithm.
* flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
usage vector. Force current usage vector to be reachable, to
optimistically signify backward jumps.
(FlowBranchingLabeled.LookupLabel): Note if a backward jump is
detected.
(FlowBranchingLabeled.Merge): New. If no backward jump was
detected, return the original salted-away usage vector instead,
updated with appropriate changes. Print unreachable warning if
necessary.
* statement.cs (Block.Resolve): Don't print unreachable warning on
a labeled statement.
In gmcs:
Fix #77869, #76148, #77755, #75255 and a host of other bugs.
This is still "wrong", but anything better would probably need a
multi-pass algorithm.
* flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
usage vector. Force current usage vector to be reachable, to
optimistically signify backward jumps.
(FlowBranchingLabeled.LookupLabel): Note if a backward jump is
detected.
(FlowBranchingLabeled.Merge): New. If no backward jump was
detected, return the original salted-away usage vector instead,
updated with appropriate changes. Print unreachable warning if
necessary.
* statement.cs (Block.Resolve): Don't print unreachable warning on
a labeled statement.
In tests:
* test-514.cs: New test from #76148.
* test-515.cs, test-516.cs: New tests based on #77755.
* test-517.cs: New test based on #75255.
In errors:
* cs0162-6.cs, cs0162-7.cs: New tests for unreachable code.
Emitting the warning on cs0162-7.cs needs a multi-pass algorithm.
* cs0165-12.cs: New test from #77869.
Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/ChangeLog 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1,3 +1,9 @@
+2006-05-18 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * cs0162-6.cs, cs0162-7.cs: New tests for unreachable code.
+ Emitting the warning on cs0162-7.cs needs a multi-pass algorithm.
+ * cs0165-12.cs: New test from #77869.
+
2006-05-11 Raja R Harinath <[EMAIL PROTECTED]>
* cs0177-7.cs: Taken from erroneous sub-test in tests/test-154.cs.
Added: trunk/mcs/errors/cs0162-6.cs
===================================================================
--- trunk/mcs/errors/cs0162-6.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/cs0162-6.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,15 @@
+// cs0162-6.cs: Unreachable code detected
+// Line: 9
+// Compiler options: -warnaserror -warn:2
+
+class Foo {
+ static void Main ()
+ {
+ goto skip;
+ a:
+ throw new System.Exception ();
+ goto a;
+ skip:
+ return;
+ }
+}
Property changes on: trunk/mcs/errors/cs0162-6.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
Name: svn:eol-style
+ native
Added: trunk/mcs/errors/cs0162-7.cs
===================================================================
--- trunk/mcs/errors/cs0162-7.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/cs0162-7.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,17 @@
+// cs0162-6.cs: Unreachable code detected
+// Line: 9
+// Compiler options: -warnaserror -warn:2
+
+// this requires a multi-pass algorithm for unreachable code detection
+// punting for now
+
+class Foo {
+ static void Main ()
+ {
+ goto skip;
+ a:
+ goto a;
+ skip:
+ return;
+ }
+}
Property changes on: trunk/mcs/errors/cs0162-7.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
Name: svn:eol-style
+ native
Added: trunk/mcs/errors/cs0165-12.cs
===================================================================
--- trunk/mcs/errors/cs0165-12.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/cs0165-12.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,28 @@
+// cs0165-12.cs: Use of unassigned local variable `foo'
+// Line: 17
+
+class X
+{
+ static void Main ()
+ {
+ int foo;
+
+ int i = 0;
+ if (i == 1)
+ goto e;
+
+ goto f;
+
+ b:
+ i += foo;
+
+ c:
+ goto b;
+
+ e:
+ foo = 5;
+
+ f:
+ goto c;
+ }
+}
Property changes on: trunk/mcs/errors/cs0165-12.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
Name: svn:eol-style
+ native
Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/known-issues-gmcs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -12,6 +12,7 @@
# as NO ERROR and CS5001 is automatically ignored.
cs0118-8.cs NO ERROR
+cs0162-7.cs NO ERROR
cs0229-2.cs
cs0229.cs NO ERROR
cs0525.cs
Modified: trunk/mcs/errors/known-issues-mcs
===================================================================
--- trunk/mcs/errors/known-issues-mcs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/errors/known-issues-mcs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -12,6 +12,7 @@
# as NO ERROR and CS5001 is automatically ignored.
cs0118-8.cs NO ERROR
+cs0162-7.cs NO ERROR
cs0229-2.cs
cs0229.cs NO ERROR
cs0525.cs
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/gmcs/ChangeLog 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1,6 +1,23 @@
+2006-05-18 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #77869, #76148, #77755, #75255 and a host of other bugs.
+ This is still "wrong", but anything better would probably need a
+ multi-pass algorithm.
+ * flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
+ usage vector. Force current usage vector to be reachable, to
+ optimistically signify backward jumps.
+ (FlowBranchingLabeled.LookupLabel): Note if a backward jump is
+ detected.
+ (FlowBranchingLabeled.Merge): New. If no backward jump was
+ detected, return the original salted-away usage vector instead,
+ updated with appropriate changes. Print unreachable warning if
+ necessary.
+ * statement.cs (Block.Resolve): Don't print unreachable warning on
+ a labeled statement.
+
2006-05-17 Gert Driesen <[EMAIL PROTECTED]>
- * driver.cs: Paass filename without path to AssemblyBuilder's
+ * driver.cs: Pass filename without path to AssemblyBuilder's
AddResourceFile. Fixes bug #78407.
2006-05-17 Raja R Harinath <[EMAIL PROTECTED]>
Modified: trunk/mcs/gmcs/flowanalysis.cs
===================================================================
--- trunk/mcs/gmcs/flowanalysis.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/gmcs/flowanalysis.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -802,12 +802,20 @@
public class FlowBranchingLabeled : FlowBranchingBlock
{
+ bool unreachable, backward_jump;
LabeledStatement stmt;
+ UsageVector actual;
+
public FlowBranchingLabeled (FlowBranching parent,
LabeledStatement stmt)
: base (parent, BranchingType.Labeled,
SiblingType.Conditional, null, stmt.loc)
{
this.stmt = stmt;
CurrentUsageVector.MergeOrigins (stmt.JumpOrigins);
+ actual = CurrentUsageVector.Clone ();
+ unreachable = actual.Reachability.IsUnreachable;
+
+ // stand-in for backward jumps
+ CurrentUsageVector.Reachability.Meet
(Reachability.Always ());
}
public override LabeledStatement LookupLabel (string name,
Location loc)
@@ -815,9 +823,26 @@
if (name != stmt.Name)
return Parent.LookupLabel (name, loc);
+ unreachable = false;
+ backward_jump = true;
+
stmt.AddReference ();
return stmt;
}
+
+ protected override UsageVector Merge ()
+ {
+ UsageVector vector = base.Merge ();
+
+ if (unreachable)
+ Report.Warning (162, 2, stmt.loc, "Unreachable
code detected");
+
+ if (backward_jump)
+ return vector;
+
+ actual.MergeChild (vector, false);
+ return actual;
+ }
}
public class FlowBranchingToplevel : FlowBranchingBlock
Modified: trunk/mcs/gmcs/statement.cs
===================================================================
--- trunk/mcs/gmcs/statement.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/gmcs/statement.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1915,7 +1915,7 @@
if (s is Block)
((Block) s).unreachable = true;
- if (!unreachable_shown) {
+ if (!unreachable_shown && !(s is
LabeledStatement)) {
Report.Warning (162, 2, s.loc,
"Unreachable code detected");
unreachable_shown = true;
}
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/mcs/ChangeLog 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1,3 +1,20 @@
+2006-05-18 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #77869, #76148, #77755, #75255 and a host of other bugs.
+ This is still "wrong", but anything better would probably need a
+ multi-pass algorithm.
+ * flowanalysis.cs (FlowBranchingLabeled): Salt away a copy of the
+ usage vector. Force current usage vector to be reachable, to
+ optimistically signify backward jumps.
+ (FlowBranchingLabeled.LookupLabel): Note if a backward jump is
+ detected.
+ (FlowBranchingLabeled.Merge): New. If no backward jump was
+ detected, return the original salted-away usage vector instead,
+ updated with appropriate changes. Print unreachable warning if
+ necessary.
+ * statement.cs (Block.Resolve): Don't print unreachable warning on
+ a labeled statement.
+
2006-05-17 Gert Driesen <[EMAIL PROTECTED]>
* driver.cs: Pass filename without path to AssemblyBuilder's
Modified: trunk/mcs/mcs/flowanalysis.cs
===================================================================
--- trunk/mcs/mcs/flowanalysis.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/mcs/flowanalysis.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -802,12 +802,20 @@
public class FlowBranchingLabeled : FlowBranchingBlock
{
+ bool unreachable, backward_jump;
LabeledStatement stmt;
+ UsageVector actual;
+
public FlowBranchingLabeled (FlowBranching parent,
LabeledStatement stmt)
: base (parent, BranchingType.Labeled,
SiblingType.Conditional, null, stmt.loc)
{
this.stmt = stmt;
CurrentUsageVector.MergeOrigins (stmt.JumpOrigins);
+ actual = CurrentUsageVector.Clone ();
+ unreachable = actual.Reachability.IsUnreachable;
+
+ // stand-in for backward jumps
+ CurrentUsageVector.Reachability.Meet
(Reachability.Always ());
}
public override LabeledStatement LookupLabel (string name,
Location loc)
@@ -815,9 +823,26 @@
if (name != stmt.Name)
return Parent.LookupLabel (name, loc);
+ unreachable = false;
+ backward_jump = true;
+
stmt.AddReference ();
return stmt;
}
+
+ protected override UsageVector Merge ()
+ {
+ UsageVector vector = base.Merge ();
+
+ if (unreachable)
+ Report.Warning (162, 2, stmt.loc, "Unreachable
code detected");
+
+ if (backward_jump)
+ return vector;
+
+ actual.MergeChild (vector, false);
+ return actual;
+ }
}
public class FlowBranchingToplevel : FlowBranchingBlock
Modified: trunk/mcs/mcs/statement.cs
===================================================================
--- trunk/mcs/mcs/statement.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/mcs/statement.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1912,7 +1912,7 @@
if (s is Block)
((Block) s).unreachable = true;
- if (!unreachable_shown) {
+ if (!unreachable_shown && !(s is
LabeledStatement)) {
Report.Warning (162, 2, s.loc,
"Unreachable code detected");
unreachable_shown = true;
}
Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/tests/ChangeLog 2006-05-18 11:02:03 UTC (rev 60813)
@@ -1,3 +1,9 @@
+2006-05-18 Raja R Harinath <[EMAIL PROTECTED]>
+
+ * test-514.cs: New test from #76148.
+ * test-515.cs, test-516.cs: New tests based on #77755.
+ * test-517.cs: New test based on #75255.
+
2006-05-17 Gert Driesen <[EMAIL PROTECTED]>
* test-513.cs: New test for bug #78407.
Added: trunk/mcs/tests/test-514.cs
===================================================================
--- trunk/mcs/tests/test-514.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/tests/test-514.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,26 @@
+// Compiler options: -warnaserror -warn:2
+
+using System;
+class X {
+
+ public static void HandleConflict (int a) {
+ if (a != 1)
+ goto throwException;
+ if (a != 2)
+ goto throwException;
+ return;
+ throwException:
+ throw new Exception ();
+ }
+
+ static int Main ()
+ {
+ int ret = 1;
+ try { HandleConflict (1); }
+ catch {
+ try { HandleConflict (2); }
+ catch { ret = 0; }
+ }
+ return ret;
+ }
+}
Property changes on: trunk/mcs/tests/test-514.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
Name: svn:eol-style
+ native
Added: trunk/mcs/tests/test-515.cs
===================================================================
--- trunk/mcs/tests/test-515.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/tests/test-515.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,13 @@
+class X {
+ static void Main ()
+ {
+ int i = 0;
+ goto a;
+ b:
+ if (++ i > 1)
+ throw new System.Exception ("infloop!!!");
+ return;
+ a:
+ goto b;
+ }
+}
Property changes on: trunk/mcs/tests/test-515.cs
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/mcs/tests/test-516.cs
===================================================================
--- trunk/mcs/tests/test-516.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/tests/test-516.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,17 @@
+// Compiler options: -warnaserror -warn:2
+
+// Same as test-515, but we're checking that there's no "unreachable code"
warning either
+
+class X {
+ static void Main ()
+ {
+ int i = 0;
+ goto a;
+ b:
+ if (++ i > 1)
+ throw new System.Exception ("infloop!!!");
+ return;
+ a:
+ goto b;
+ }
+}
Property changes on: trunk/mcs/tests/test-516.cs
___________________________________________________________________
Name: svn:mime-type
+ text/cpp
Name: svn:eol-style
+ native
Added: trunk/mcs/tests/test-517.cs
===================================================================
--- trunk/mcs/tests/test-517.cs 2006-05-18 01:52:30 UTC (rev 60812)
+++ trunk/mcs/tests/test-517.cs 2006-05-18 11:02:03 UTC (rev 60813)
@@ -0,0 +1,12 @@
+// Compiler options: -warnaserror -warn:2
+
+class Test {
+ public static int Main ()
+ {
+ int i = 1;
+ goto lbl;
+ lbl:
+ i = 0;
+ return i;
+ }
+}
Property changes on: trunk/mcs/tests/test-517.cs
___________________________________________________________________
Name: svn:eol-style
+ native
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches