Author: atsushi
Date: 2005-03-10 11:10:50 -0500 (Thu, 10 Mar 2005)
New Revision: 41649

Added:
   trunk/mcs/errors/cs1041.cs
   trunk/mcs/tests/xml-036-ref.xml
   trunk/mcs/tests/xml-036.cs
Modified:
   trunk/mcs/errors/ChangeLog
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/cs-tokenizer.cs
   trunk/mcs/mcs/doc.cs
   trunk/mcs/tests/ChangeLog
   trunk/mcs/tests/Makefile
Log:
2004-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>

        in mcs:
        * cs-tokenizer.cs : added IsKeyword().
        * doc.cs : Detect keyword incorrectly used as identifier.
          Allow identifiers prefixed by @.

        in tests:
        * xml-036.cs, xml-036-ref.xml, Makefile : added test for bug #73384.

        in errors:
        * cs1041.cs : added test for bug #73385.



Modified: trunk/mcs/errors/ChangeLog
===================================================================
--- trunk/mcs/errors/ChangeLog  2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/errors/ChangeLog  2005-03-10 16:10:50 UTC (rev 41649)
@@ -1,3 +1,7 @@
+2004-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * cs1041.cs : added test for bug #73385.
+
 2005-03-10 Marek Safar <[EMAIL PROTECTED]>
 
        * TestRunner.cs: New fast test runner.

Added: trunk/mcs/errors/cs1041.cs
===================================================================
--- trunk/mcs/errors/cs1041.cs  2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/errors/cs1041.cs  2005-03-10 16:10:50 UTC (rev 41649)
@@ -0,0 +1,12 @@
+// warning CS1041: Identifier expected, 'true' is a keyword
+// warning CS1041: Identifier expected, 'catch' is a keyword
+// Compiler options: -warnaserror
+
+/// <summary><see cref="true" />, <see cref="catch" /></summary>
+public enum Test {
+        /// <summary>Maybe</summary>
+        @true,
+
+        /// <summary>Maybe</summary>
+        @catch
+}

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/mcs/ChangeLog     2005-03-10 16:10:50 UTC (rev 41649)
@@ -1,3 +1,9 @@
+2004-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * cs-tokenizer.cs : added IsKeyword().
+       * doc.cs : Detect keyword incorrectly used as identifier.
+         Allow identifiers prefixed by @.
+
 2005-03-10  Marek Safar  <[EMAIL PROTECTED]>
 
        * attributes.cs (Attributes.Emit): Continue after CheckTargets.

Modified: trunk/mcs/mcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/mcs/cs-tokenizer.cs       2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/mcs/cs-tokenizer.cs       2005-03-10 16:10:50 UTC (rev 41649)
@@ -162,6 +162,7 @@
                // Class variables
                // 
                static CharArrayHashtable[] keywords;
+               static Hashtable keywordStrings = new Hashtable ();
                static NumberStyles styles;
                static NumberFormatInfo csharp_format_info;
                
@@ -222,6 +223,7 @@
                }
 
                static void AddKeyword (string kw, int token) {
+                       keywordStrings.Add (kw, kw);
                        if (keywords [kw.Length] == null) {
                                keywords [kw.Length] = new CharArrayHashtable 
(kw.Length);
                        }
@@ -405,12 +407,17 @@
                {
                        return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') 
|| c == '_' || (c >= '0' && c <= '9') || Char.IsLetter (c);
                }
-               
+
+               public static bool IsKeyword (string s)
+               {
+                       return keywordStrings [s] != null;
+               }
+
                public static bool IsValidIdentifier (string s)
                {
                        if (s == null || s.Length == 0)
                                return false;
-                       
+
                        if (!is_identifier_start_character (s [0]))
                                return false;
                        

Modified: trunk/mcs/mcs/doc.cs
===================================================================
--- trunk/mcs/mcs/doc.cs        2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/mcs/doc.cs        2005-03-10 16:10:50 UTC (rev 41649)
@@ -504,6 +504,7 @@
                                name = signature;
                                parameters = String.Empty;
                        }
+                       Normalize (mc, ref name);
 
                        string identifier = name;
 
@@ -516,15 +517,16 @@
                        // Check if identifier is valid.
                        // This check is not necessary to mark as error, but
                        // csc specially reports CS1584 for wrong identifiers.
-                       foreach (string nameElem in identifier.Split ('.')) {
+                       string [] nameElems = identifier.Split ('.');
+                       for (int i = 0; i < nameElems.Length; i++) {
+                               string nameElem = nameElems [i];
+                               if (nameElem.EndsWith ("[]"))
+                                       nameElem = nameElem.Substring (
+                                               nameElem.Length - 2);
+                               if (i > 0)
+                                       Normalize (mc, ref nameElem);
                                if (!Tokenizer.IsValidIdentifier (nameElem)
                                        && nameElem.IndexOf ("operator") < 0) {
-                                       if (nameElem.EndsWith ("[]") &&
-                                               Tokenizer.IsValidIdentifier (
-                                               nameElem.Substring (
-                                               0, nameElem.Length - 2)))
-                                               continue;
-
                                        Report.Warning (1584, 1, mc.Location, 
"XML comment on '{0}' has syntactically incorrect attribute '{1}'", 
mc.GetSignatureForError (), cref);
                                        xref.SetAttribute ("cref", "!:" + 
signature);
                                        return;
@@ -538,6 +540,7 @@
                                ArrayList plist = new ArrayList ();
                                for (int i = 0; i < paramList.Length; i++) {
                                        string paramTypeName = paramList 
[i].Trim (wsChars);
+                                       Normalize (mc, ref paramTypeName);
                                        Type paramType = FindDocumentedType 
(mc, paramTypeName, ds, cref);
                                        if (paramType == null) {
                                                Report.Warning (1580, 1, 
mc.Location, "Invalid type for parameter '{0}' in XML comment cref attribute 
'{1}'", i + 1, cref);
@@ -574,6 +577,7 @@
                        if (period > 0) {
                                string typeName = name.Substring (0, period);
                                string memberName = name.Substring (period + 1);
+                               Normalize (mc, ref memberName);
                                type = FindDocumentedType (mc, typeName, ds, 
cref);
                                int warnResult;
                                if (type != null) {
@@ -706,6 +710,38 @@
                                GenerateDocComment (mc, e);
                        }
                }
+
+               private static void Normalize (MemberCore mc, ref string name)
+               {
+                       if (name.Length > 0 && name [0] == '@')
+                               name = name.Substring (1);
+                       else if (Tokenizer.IsKeyword (name) && !IsTypeName 
(name))
+                               Report.Warning (1041, 1, mc.Location, 
String.Format ("Identifier expected, '{0}' is a keyword", name));
+               }
+
+               private static bool IsTypeName (string name)
+               {
+                       switch (name) {
+                       case "bool":
+                       case "byte":
+                       case "char":
+                       case "decimal":
+                       case "double":
+                       case "float":
+                       case "int":
+                       case "long":
+                       case "object":
+                       case "sbyte":
+                       case "short":
+                       case "string":
+                       case "uint":
+                       case "ulong":
+                       case "ushort":
+                       case "void":
+                               return true;
+                       }
+                       return false;
+               }
        }
 
        //

Modified: trunk/mcs/tests/ChangeLog
===================================================================
--- trunk/mcs/tests/ChangeLog   2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/tests/ChangeLog   2005-03-10 16:10:50 UTC (rev 41649)
@@ -1,3 +1,7 @@
+2005-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * xml-036.cs, xml-036-ref.xml, Makefile : added test for bug #73384.
+
 2005-03-10  Raja R Harinath  <[EMAIL PROTECTED]>
 
        * mtest-7-exe.cs, mtest-7-dll.cs: New test from #73516.

Modified: trunk/mcs/tests/Makefile
===================================================================
--- trunk/mcs/tests/Makefile    2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/tests/Makefile    2005-03-10 16:10:50 UTC (rev 41649)
@@ -28,7 +28,7 @@
 # Martin Baulig will manually move them into TEST_SOURCES_common after merging 
the code into GMCS.
 # He may also move some to TEST_EXCLUDE_net_2_0 if some of the merges are 
inappropriate for GMCS.
 #
-NEW_TEST_SOURCES_common = xml-033 xml-034 xml-035 test-329 2test-16 test-330 
a-parameter5 test-331 test-332 \
+NEW_TEST_SOURCES_common = xml-033 xml-034 xml-035 xml-036 test-329 2test-16 
test-330 a-parameter5 test-331 test-332 \
                          test-333 test-311 test-335 test-336 test-337 test-287 
test-338 test-339 test-341 test-334 test-342 \
                          test-344 test-345 test-346 test-347 test-348 test-349 
test-351 test-352 test-353 test-354 test-355 \
                          test-356 test-357 \

Added: trunk/mcs/tests/xml-036-ref.xml
===================================================================
--- trunk/mcs/tests/xml-036-ref.xml     2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/tests/xml-036-ref.xml     2005-03-10 16:10:50 UTC (rev 41649)
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<doc>
+    <assembly>
+        <name>xml-036</name>
+    </assembly>
+    <members>
+        <member name="T:Test">
+            <summary><see cref="F:Test.true"/>, <see cref="F:Test.true"/>, 
<see cref="F:Test.Whatever"/></summary>
+        </member>
+        <member name="F:Test.true">
+            <summary>Yes</summary>
+        </member>
+        <member name="F:Test.false">
+            <summary>Nope</summary>
+        </member>
+        <member name="F:Test.Whatever">
+            <summary>Maybe</summary>
+        </member>
+        <member name="T:Foo">
+            <summary><see cref="M:Foo.true"/></summary>
+        </member>
+        <member name="M:Foo.true">
+            <summary>Foo</summary>
+        </member>
+        <member name="M:Foo.Main">
+            main.
+        </member>
+    </members>
+</doc>

Added: trunk/mcs/tests/xml-036.cs
===================================================================
--- trunk/mcs/tests/xml-036.cs  2005-03-10 16:06:59 UTC (rev 41648)
+++ trunk/mcs/tests/xml-036.cs  2005-03-10 16:10:50 UTC (rev 41649)
@@ -0,0 +1,18 @@
+// Compiler options: -doc:xml-036.xml -warn:1 -warnaserror
+/// <summary><see cref="@true" />, <see cref="[EMAIL PROTECTED]" />, <see 
cref="@Whatever" /></summary>
+public enum Test {
+       /// <summary>Yes</summary>
+       @true,
+       /// <summary>Nope</summary>
+       @false,
+       /// <summary>Maybe</summary>
+       Whatever
+}
+
+/// <summary><see cref="[EMAIL PROTECTED]" /></summary>
+public abstract class Foo {
+       /// <summary>Foo</summary>
+       public abstract void @true();
+       /// main.
+       public static void Main() {}
+}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to