diff options
author | Raja R Harinath <harinath@hurrynot.org> | 2006-04-20 15:14:15 +0400 |
---|---|---|
committer | Raja R Harinath <harinath@hurrynot.org> | 2006-04-20 15:14:15 +0400 |
commit | 9062bd541121b966ec9dc179c56a571b546eda14 (patch) | |
tree | f3311dc7868c0bdebbc21c26097ff41277cce13d /mcs | |
parent | ef75d63d4134991461c52aff9318a72ee578a5b6 (diff) |
In mcs and gmcs:
Fix #66031
* statement.cs (Block.UsageWarning): Allow VariableInfo to be null.
(Catch.Resolve): Resolve VarBlock if it exists.
In errors:
* cs0168-2.cs: New test from #66031.
svn path=/trunk/mcs/; revision=59691
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/errors/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/errors/cs0168-2.cs | 14 | ||||
-rw-r--r-- | mcs/gmcs/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/gmcs/statement.cs | 19 | ||||
-rw-r--r-- | mcs/mcs/ChangeLog | 6 | ||||
-rw-r--r-- | mcs/mcs/statement.cs | 17 |
6 files changed, 57 insertions, 9 deletions
diff --git a/mcs/errors/ChangeLog b/mcs/errors/ChangeLog index 963281d76cd..9daf5e3d0af 100644 --- a/mcs/errors/ChangeLog +++ b/mcs/errors/ChangeLog @@ -1,3 +1,7 @@ +2006-04-20 Raja R Harinath <rharinath@novell.com> + + * cs0168-2.cs: New test from #66031. + 2006-04-18 Raja R Harinath <rharinath@novell.com> * cs1690.cs, cs1690-2.cs, cs1690-3.cs: Update. diff --git a/mcs/errors/cs0168-2.cs b/mcs/errors/cs0168-2.cs new file mode 100644 index 00000000000..c53df44d12e --- /dev/null +++ b/mcs/errors/cs0168-2.cs @@ -0,0 +1,14 @@ +// cs0168-2.cs: The variable `e' is declared but never used +// Line: 10 +// Compiler options: -warn:3 -warnaserror + +using System; + +public class ConsoleStub { + public static void Main(string[] args) { + try { + } catch (Exception e) { + } + } +} + diff --git a/mcs/gmcs/ChangeLog b/mcs/gmcs/ChangeLog index d556a8c582b..75c2736c64c 100644 --- a/mcs/gmcs/ChangeLog +++ b/mcs/gmcs/ChangeLog @@ -1,3 +1,9 @@ +2006-04-20 Raja R Harinath <rharinath@novell.com> + + Fix #66031 + * statement.cs (Block.UsageWarning): Allow VariableInfo to be null. + (Catch.Resolve): Resolve VarBlock if it exists. + 2006-04-19 Miguel de Icaza <miguel@novell.com> * statement.cs (Foreach.EmitFinally): Do not emit the enumerator diff --git a/mcs/gmcs/statement.cs b/mcs/gmcs/statement.cs index d77ef34f429..dd105e4032e 100644 --- a/mcs/gmcs/statement.cs +++ b/mcs/gmcs/statement.cs @@ -1834,13 +1834,14 @@ namespace Mono.CSharp { if ((variables != null) && (RootContext.WarningLevel >= 3)) { foreach (DictionaryEntry de in variables){ LocalInfo vi = (LocalInfo) de.Value; - + if (vi.Used) continue; - + name = (string) de.Key; - - if (vector.IsAssigned (vi.VariableInfo)){ + + // vi.VariableInfo can be null for 'catch' variables + if (vi.VariableInfo != null && vector.IsAssigned (vi.VariableInfo)){ Report.Warning (219, 3, vi.Location, "The variable `{0}' is assigned but its value is never used", name); } else { Report.Warning (168, 3, vi.Location, "The variable `{0}' is declared but never used", name); @@ -3605,7 +3606,15 @@ namespace Mono.CSharp { } else type = null; - return Block.Resolve (ec); + if (!Block.Resolve (ec)) + return false; + + // Even though VarBlock surrounds 'Block' we resolve it later, so that we can correctly + // emit the "unused variable" warnings. + if (VarBlock != null) + return VarBlock.Resolve (ec); + + return true; } finally { ec.InCatch = was_catch; diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index aca8aa3a884..a819bc34059 100644 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,9 @@ +2006-04-20 Raja R Harinath <rharinath@novell.com> + + Fix #66031 + * statement.cs (Block.UsageWarning): Allow VariableInfo to be null. + (Catch.Resolve): Resolve VarBlock if it exists. + 2006-04-19 Miguel de Icaza <miguel@novell.com> * statement.cs (Foreach.EmitFinally): Do not emit the enumerator diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs index 702ff5bbee8..c235064f707 100644 --- a/mcs/mcs/statement.cs +++ b/mcs/mcs/statement.cs @@ -1834,13 +1834,14 @@ namespace Mono.CSharp { if ((variables != null) && (RootContext.WarningLevel >= 3)) { foreach (DictionaryEntry de in variables){ LocalInfo vi = (LocalInfo) de.Value; - + if (vi.Used) continue; - + name = (string) de.Key; - if (vector.IsAssigned (vi.VariableInfo)){ + // vi.VariableInfo can be null for 'catch' variables + if (vi.VariableInfo != null && vector.IsAssigned (vi.VariableInfo)){ Report.Warning (219, 3, vi.Location, "The variable `{0}' is assigned but its value is never used", name); } else { Report.Warning (168, 3, vi.Location, "The variable `{0}' is declared but never used", name); @@ -3604,7 +3605,15 @@ namespace Mono.CSharp { } else type = null; - return Block.Resolve (ec); + if (!Block.Resolve (ec)) + return false; + + // Even though VarBlock surrounds 'Block' we resolve it later, so that we can correctly + // emit the "unused variable" warnings. + if (VarBlock != null) + return VarBlock.Resolve (ec); + + return true; } finally { ec.InCatch = was_catch; |