Bug 325294 (MONO82627) - [Mono-1.2.4]-gmcs-EnumTypeAndUsingStatementBug
Summary: [Mono-1.2.4]-gmcs-EnumTypeAndUsingStatementBug
Status: RESOLVED NORESPONSE
Alias: MONO82627
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-29 18:00 UTC by Min,Lei
Modified: 2008-07-10 10:47 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
gmcs_bad.exe can not support enum and usingstatement, gmcs_good_not_for_using.exe can not support using statement, gmcs_good_for_using.exe support both (981.61 KB, application/octet-stream)
2007-08-29 18:04 UTC, Thomas Wiest
Details
a.diff file (573 bytes, patch)
2007-08-29 19:15 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:50:50 UTC


---- Reported by lei.min@gmx.de 2007-08-29 11:00:05 MST ----

Description of Problem:
i have by myself build the gmcs.exe under Visual C# 2005 Express Edition.
the gmcs.exe hat three known bugs in the source. the bugs are:
gmcs.exe can not compile C# source which includes enum type define,which
has a usingstatement with var_declaration
(for example: using(ClassA a=new ClassA());)
i am trying myself to debug these. and found some changes, it can resolve
these bugs. but i am not sure ,if those changes are correct.

> mcs\typemanager.cs
> //public static void AddUserType(DeclSpace ds)
> //{
> //+ if (ds is Enum)
> //+ {
> //+ ds.TypeBuilder = ds.DefineType();
> //+ }
> // builder_to_declspace.Add(ds.TypeBuilder, ds);
> //} line 401,410 typemanager.cs patch for the Enum to remove:
> // InvalidOperationException ("enum basetype is not defined");
> //
> mcs\ecore.cs
> //public override object GetTypedValue ()
> //{
> // // FIXME: runtime is not ready to work with just emited enums
> // if (!RootContext.StdLib) {
> // return Child.GetValue ();
> // }
> //
> //+ return Child.GetValue();
> //- return System.Enum.ToObject (type, Child.GetValue ());
> //} line 1538,1547 ecore.cs patch for the Enum to remove:
> // ArgumentException ("enumType must be a runtime type");

> mcs\statement.cs
> //- if (emit_finally)
> //-    ig.BeginFinallyBlock();
> 
> // line 4512,4516 statement.cs remove the ArgumentException in using
statement, because
> // ig.BeginFinallyBlock() has been called in the method
DoEmitFinally(EmitContext) in the Class ExceptionStatement

> //				if (emit_finally)
> //					ig.BeginExceptionBlock ();
> //				assign [i].Emit (ec);
> //orignal is: 
> //              assign [i].Emit (ec);
> //
> //				if (emit_finally)
> //					ig.BeginExceptionBlock ();
> //
> // line 4490,4495  statement.cs assign[i].Emit should be after the
BeginExceptionBlock,because assign has referenced the local variable
> //  and it will call Dispose(); in the finallyblock, or we can in finally
block generate a local copy for the variable.


> //		protected override void CloneTo (CloneContext clonectx, Statement t)
> //		{
> //			Using target = (Using) t;
> //
> //			if (expression_or_block is Expression)
> //				target.expression_or_block = ((Expression)
expression_or_block).Clone (clonectx);
> //			else
> //-				target.expression_or_block = ((DictionaryEntry)
expression_or_block).Clone (clonectx);
> //+             target.expression_or_block = expression_or_block;
> //			
> //			target.Statement = Statement.Clone (clonectx);
> //		}
> // line 4670,4685 statement.cs



here is another bug in the statement.cs ,but i can not change.
> mcs\statement.cs
> in Class Using:
> // protected override void CloneTo (CloneContext clonectx, Statement t)
> // {
> // Using target = (Using) t;
> // if (expression_or_block is Expression)
> // target.expression_or_block =
> ((Expression)expression_or_block).Clone(clonectx);
> // else
> // error--->> target.expression_or_block = ((Statement)
> expression_or_block).Clone (clonectx);
> // } line 4670,4685 expression_or_block is either a Expression or a
> DictionaryEntry, not a Statement.



---- Additional Comments From lei.min@gmx.de 2007-08-29 11:04:05 MST ----

Created an attachment (id=172577)
gmcs_bad.exe can not support enum and usingstatement, gmcs_good_not_for_using.exe can not support using statement, gmcs_good_for_using.exe support both




---- Additional Comments From marek.safar@seznam.cz 2007-08-29 11:26:47 MST ----

Please use unified diff for your proposed changes.



---- Additional Comments From lei.min@gmx.de 2007-08-29 12:15:21 MST ----

Created an attachment (id=172578)
a.diff file


Imported an attachment (id=172577)
Imported an attachment (id=172578)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows with .net framework 2.0</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Marek Safar 2007-10-05 20:49:56 UTC
Can you please provide a test case which show an issue which your changes should fix ?
Comment 2 Marek Safar 2008-07-10 10:47:26 UTC
No response