Author: martin
Date: 2005-04-15 12:05:35 -0400 (Fri, 15 Apr 2005)
New Revision: 43058

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/cs-tokenizer.cs
   trunk/mcs/gmcs/doc.cs
Log:
**** Merged r41649-r41677 from MCS ****


Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-04-15 16:04:22 UTC (rev 43057)
+++ trunk/mcs/gmcs/ChangeLog    2005-04-15 16:05:35 UTC (rev 43058)
@@ -1,3 +1,22 @@
+2004-03-11  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * doc.cs : just eliminate the latest change.
+
+2004-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * doc.cs : commented out the latest change. It breaks xml-030.cs
+
+2004-03-10  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * doc.cs : When TypeBuilder did not create Type yet, GetEvents() will
+         fail. So invoke CreateType() in FindDocumentedType().
+
+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/gmcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/gmcs/cs-tokenizer.cs      2005-04-15 16:04:22 UTC (rev 43057)
+++ trunk/mcs/gmcs/cs-tokenizer.cs      2005-04-15 16:05:35 UTC (rev 43058)
@@ -183,6 +183,7 @@
                // Class variables
                // 
                static CharArrayHashtable[] keywords;
+               static Hashtable keywordStrings = new Hashtable ();
                static NumberStyles styles;
                static NumberFormatInfo csharp_format_info;
                
@@ -243,6 +244,7 @@
                }
 
                static void AddKeyword (string kw, int token) {
+                       keywordStrings.Add (kw, kw);
                        if (keywords [kw.Length] == null) {
                                keywords [kw.Length] = new CharArrayHashtable 
(kw.Length);
                        }
@@ -429,12 +431,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/gmcs/doc.cs
===================================================================
--- trunk/mcs/gmcs/doc.cs       2005-04-15 16:04:22 UTC (rev 43057)
+++ trunk/mcs/gmcs/doc.cs       2005-04-15 16:05:35 UTC (rev 43058)
@@ -500,6 +500,7 @@
                                name = signature;
                                parameters = String.Empty;
                        }
+                       Normalize (mc, ref name);
 
                        string identifier = name;
 
@@ -512,15 +513,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;
@@ -534,6 +536,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);
@@ -570,6 +573,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) {
@@ -702,6 +706,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;
+               }
        }
 
        //

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

Reply via email to