Bug 318888 (MONO75984) - [PATCH] Several preprocessor handling bugfixes
Summary: [PATCH] Several preprocessor handling bugfixes
Status: RESOLVED FIXED
Alias: MONO75984
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Marek Safar
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-05 11:36 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

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


Attachments
proposed fix (3.06 KB, patch)
2005-09-05 11:36 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 19:29:26 UTC


---- Reported by atsushi@ximian.com 2005-09-05 04:36:07 MST ----

Copying from
http://lists.ximian.com/pipermail/mono-devel-list/2005-August/014329.html

As for existing mcs:

	- It didn't report expected location (tiny fix).
	- When -langversion:ISO-1 is specified, #pragma directive
	  is always checked, even when it is actually disabled
	  by #if directive. (Because of this bug, currently
	  mscorlib cannot be compiled with csc.)
	- Syntax for #define and #undef are checked even when
	  they are inside disabled block.
	- On the other hand, syntax for #line directive is
	  not checked unless it is enabled.

-------- repro
#if false
#line hahaha // invalid format -> no error
#error
#line hahaha // invalid format -> no error
#undef // without identifier -> error
#line hahaha // invalid format -> no error
#pragma warning disable 3005 // wrong directive on csc 1.x
	public class Foo
	{
	}
#pragma warning restore // wrong directive on csc 1.x

#region // blank -> no error
#endregion
#region Foo // without endregion -> error
#hogehoge // wrong directive

#endif
--------

Actual Results:

pragma-warning.cs(1,1): error CS1576: The line number specified for #line
directive is missing or invalid
pragma-warning.cs(1,1): error CS1576: The line number specified for #line
directive is missing or invalid
pragma-warning.cs(1,1): error CS1576: The line number specified for #line
directive is missing or invalid
pragma-warning.cs(1,1): warning CS1691: `3005' is not a valid warning number
pragma-warning.cs(1,1): error CS1038: #endregion directive expected
pragma-warning.cs(1,1): error CS1027: Expected `#endif' directive
error CS1027: Expected `#endif' directive
Compilation failed: 6 error(s), 1 warnings

Expected Results:

pragma-warning.cs(5,8): error CS1001: Identifier expected
pragma-warning.cs(16,2): error CS1024: Preprocessor directive expected
pragma-warning.cs(18,2): error CS1038: #endregion directive expected
pragma-warning.cs(20,1): error CS1027: #endif directive expected

This had been blocking mscorlib compilation with csc (as ConsoleKey.cs was
incorrectly allowed to have such code).



---- Additional Comments From atsushi@ximian.com 2005-09-05 04:36:36 MST ----

Created an attachment (id=168463)
proposed fix




---- Additional Comments From atsushi@ximian.com 2005-09-05 04:49:39 MST ----

Well, precisely to say, .NET 1.x csc reports:

pragma-warning.cs(5,8): error CS1001: Identifier expected
pragma-warning.cs(7,2): error CS1024: Preprocessor directive expected
pragma-warning.cs(11,2): error CS1024: Preprocessor directive expected
pragma-warning.cs(16,2): error CS1024: Preprocessor directive expected
pragma-warning.cs(18,2): error CS1038: #endregion directive expected
pragma-warning.cs(20,1): error CS1027: #endif directive expected

while 2.0 csc with -langversion:ISO-1 tells above (btw I believe it is
a bug in 2.0 csc that it does not reject #pragma directive).



---- Additional Comments From martin@ximian.com 2005-12-08 13:08:59 MST ----

Patch looks good.



---- Additional Comments From atsushi@ximian.com 2005-12-09 06:20:41 MST ----

Applied the patch, with a small change (#pragma won't be checked
strictly even when ISO-1 mode is specified; it is what Miguel and I
once agreed.)



---- Additional Comments From atsushi@ximian.com 2005-12-12 03:02:28 MST ----

Forgot to reopen; the patch was reverted



---- Additional Comments From marek.safar@seznam.cz 2006-12-10 08:44:59 MST ----

Fixed in SVN.

Imported an attachment (id=168463)

Unknown operating system unknown. Setting to default OS "Other".