[Mono-dev] mcs patch to report Const location

Marek Safar marek.safar at seznam.cz
Thu Aug 18 12:57:48 EDT 2005


Hello Eno,

>>> I noticed that mcs does not report locations for constants. The
>>> attached patch fixes this matter. The patch is pretty massive
>>> (as I had to compress it), but the fixes are pretty simple - I
>>> just added Location parameter to everywhere BlahConstant is
>>> created.
>>>  
>>>
>> Unfortunately not for constants only. Could you make diff against mcs
>> SVN HEAD version ?
>
>
> The patch got out of date (just in two days after) - anyways
> attached the patch for the latest head.

Oups, something is wrong I got it today.
However, not sure about this patch. I am not convinced about usefulness 
of this patch. On several places this location doesn't make any sense.
For instance

+        public static Constant Constantify (Type t, Location loc)
         {

This method converts 'new int()' syntax not zero constant. I think if 
someone uses this location it is mcs coding error because it is not real 
constant.

In similar way here

         public override Constant Increment ()
         {
-            return new ByteConstant (checked ((byte)(Value + 1)));
+            return new ByteConstant (checked ((byte)(Value + 1)), loc);
         }

Returned constant is not real constant (it doesn't have any reference to 
source code) it is more like operator.

>>> BTW I noticed that compiler-tester does not work fine for libs
>>> and partial sources - maybe someone missed to commit it?
>>>  
>>>
>> Could you be more specific ?
>
>
> It stops at *-lib.cs, saying below:
>
> test-317.cs...  OK
> test-318.cs...  OK
> test-319-lib.cs...
> Unhandled Exception: System.NullReferenceException: Object reference 
> not set to an instance of an object
> in [0x00020] (at 
> C:\cygwin\home\atsushi\svn\mcs\tools\compiler-tester\compiler-tester.cs:395) 
> TestRunner.PositiveChecker:ExecuteFile (System.Reflection.MethodInfo 
> entry_point, System.String filename)
> in [0x00147] (at 
> C:\cygwin\home\atsushi\svn\mcs\tools\compiler-tester\compiler-tester.cs:353) 
> TestRunner.PositiveChecker:Check (System.String filename)
> in [0x0006c] (at 
> C:\cygwin\home\atsushi\svn\mcs\tools\compiler-tester\compiler-tester.cs:153) 
> TestRunner.Checker:Do (System.String filename)
> in [0x00150] (at 
> C:\cygwin\home\atsushi\svn\mcs\tools\compiler-tester\compiler-tester.cs:687) 
> TestRunner.Tester:Main (System.String[] args)
> make[1]: *** [run-test-local] Error 1
> make[1]: Leaving directory `/home/atsushi/svn/mcs/tests'
> make: *** [do-run-test] Error 1
>
> The attached workaround (not a fix) lets run-test completed, but
> it still reports below:
>
> The latest changes caused regression in 4 file(s)
> test-353-p2.cs
> test-361-p2.cs
> test-388-p2.cs
> test-389-p2.cs
>
> They happen even though I haven't made any changes.

This looks strange. Are you using mono or Microsoft runtime ?

Marek




More information about the Mono-devel-list mailing list