Author: duncan
Date: 2005-03-07 23:12:16 -0500 (Mon, 07 Mar 2005)
New Revision: 41544

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/codegen.cs
   trunk/mcs/mcs/convert.cs
   trunk/mcs/mcs/cs-tokenizer.cs
   trunk/mcs/mcs/expression.cs
Log:
2005-03-07  Duncan Mak  <[EMAIL PROTECTED]>

        * codegen.cs (Save):  Catch UnauthorizedAccessException as
        well. Fixes bug #73454.


Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2005-03-08 00:23:15 UTC (rev 41543)
+++ trunk/mcs/mcs/ChangeLog     2005-03-08 04:12:16 UTC (rev 41544)
@@ -1,3 +1,8 @@
+2005-03-07  Duncan Mak  <[EMAIL PROTECTED]>
+
+       * codegen.cs (Save):  Catch UnauthorizedAccessException as
+       well. Fixes bug #73454.
+
 2005-03-07  Marek Safar  <[EMAIL PROTECTED]>
 
        * cs-tokenizer.cs (xtoken): Add CS1035.

Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs    2005-03-08 00:23:15 UTC (rev 41543)
+++ trunk/mcs/mcs/codegen.cs    2005-03-08 04:12:16 UTC (rev 41544)
@@ -172,6 +172,9 @@
                        catch (System.IO.IOException io) {
                                Report.Error (16, "Could not write to file 
`"+name+"', cause: " + io.Message);
                        }
+                       catch (System.UnauthorizedAccessException ua) {
+                               Report.Error (16, "Could not write to file 
`"+name+"', cause: " + ua.Message);
+                       }
 
                        if (SymbolWriter != null)
                                SymbolWriter.WriteSymbolFile ();

Modified: trunk/mcs/mcs/convert.cs
===================================================================
--- trunk/mcs/mcs/convert.cs    2005-03-08 00:23:15 UTC (rev 41543)
+++ trunk/mcs/mcs/convert.cs    2005-03-08 04:12:16 UTC (rev 41544)
@@ -1036,20 +1036,27 @@
                        if (method == null || count > 1)
                                return null;
                        
-                       
+                       Expression original_source = source;
                        //
                        // This will do the conversion to the best match that we
-                       // found.  Now we need to perform an implict standard 
conversion
+                       // found.  Now we need to perform an implicit standard 
conversion
                        // if the best match was not the type that we were 
requested
                        // by target.
                        //
                        if (look_for_explicit)
-                               source = ExplicitConversionStandard (ec, 
source, most_specific_source, loc);
+                               source = ExplicitConversionStandard (ec, 
original_source, most_specific_source, loc);
                        else
-                               source = ImplicitConversionStandard (ec, 
source, most_specific_source, loc);
+                               source = ImplicitConversionStandard (ec, 
original_source, most_specific_source, loc);
 
-                       if (source == null)
-                               return null;
+                       //
+                       // If ImplicitConversionStandard comes up with nothing, 
try UserDefinedConversion 
+                       // again, because a UserCast might be able to cast 
`original_source' into `most_specific_source'.
+                       //
+                       if (source == null) {
+                               source = UserDefinedConversion (ec, 
original_source, most_specific_source, loc, false);
+                               if (source == null)
+                                       return null;
+                       }
 
                        Expression e;
                        e =  new UserCast ((MethodInfo) method, source, loc);

Modified: trunk/mcs/mcs/cs-tokenizer.cs
===================================================================
--- trunk/mcs/mcs/cs-tokenizer.cs       2005-03-08 00:23:15 UTC (rev 41543)
+++ trunk/mcs/mcs/cs-tokenizer.cs       2005-03-08 04:12:16 UTC (rev 41544)
@@ -1947,11 +1947,14 @@
                                        } else if (d == '*'){
                                                getChar ();
                                                bool docAppend = false;
+                                               bool expecting_end_of_comment = 
true;
+                                               
                                                if (RootContext.Documentation 
!= null && peekChar () == '*') {
                                                        getChar ();
                                                        // But when it is /**/, 
just do nothing.
                                                        if (peekChar () == '/') 
{
                                                                getChar ();
+                                                               
expecting_end_of_comment = false;
                                                                continue;
                                                        }
                                                        if (doc_state == 
XmlCommentState.Allowed)
@@ -1973,6 +1976,7 @@
                                                                getChar ();
                                                                col++;
                                                                comments_seen = 
true;
+                                                               
expecting_end_of_comment = false;
                                                                break;
                                                        }
                                                        if (docAppend)
@@ -1996,6 +2000,10 @@
 
                                                if (docAppend)
                                                        
update_formatted_doc_comment (current_comment_start);
+
+                                               if (expecting_end_of_comment)
+                                                       Report.Error (1035, 
Location, "End-of-file found, '*/' expected");
+                                               
                                                continue;
                                        }
                                        goto is_punct_label;

Modified: trunk/mcs/mcs/expression.cs
===================================================================
--- trunk/mcs/mcs/expression.cs 2005-03-08 00:23:15 UTC (rev 41543)
+++ trunk/mcs/mcs/expression.cs 2005-03-08 04:12:16 UTC (rev 41544)
@@ -2400,9 +2400,6 @@
 
                                        if (l == r)
                                                return this;
-                                       
-                                       if (l.IsSubclassOf (r) || 
r.IsSubclassOf (l))
-                                               return this;
 
                                        //
                                        // Also, a standard conversion must 
exist from either one
@@ -2421,9 +2418,17 @@
                                                right = new EmptyCast (right, 
TypeManager.object_type);
 
                                        //
-                                       // FIXME: CSC here catches errors cs254 
and cs252
-                                       //
-                                       return this;
+                                       // Report CS0252 / CS0253 if we have to 
invoke Object.op_Equality
+                                       // even when either l or r implements 
of op_Equality.
+                                       // 
+                                       if (!HasEqualityOperatorForType (l, r))
+                                               
Warning_UnintendedReferenceComparison (loc, "right", r.FullName);
+                                       
+                                       else if (!HasEqualityOperatorForType 
(r, l))
+                                               
Warning_UnintendedReferenceComparison (loc, "left", l.FullName);
+
+                                       if (l.IsSubclassOf (r) || 
r.IsSubclassOf (l))
+                                               return this;
                                }
 
                                //
@@ -2693,6 +2698,29 @@
                        return this;
                }
 
+               // Checks whether or not 'container' has op_Equality that can 
handle 'comparison_type'.
+               public static bool HasEqualityOperatorForType (Type container, 
Type comparison_type)
+               {
+                       // Can't call GetMethod here as there could be multiple 
impl. of op_Equality.
+                       MethodInfo [] methods = container.GetMethods ();
+                       foreach (MethodInfo m in methods) {
+                               if (m.Name == "op_Equality") {
+                                       foreach (ParameterInfo param in 
m.GetParameters ()) {
+                                               if (param.ParameterType == 
comparison_type)
+                                                       return true;
+                                       }
+                               }
+                       }
+                       return false;
+               }
+
+               public static void Warning_UnintendedReferenceComparison 
(Location loc, string direction, string type_name)
+               {
+                       Report.Warning ((direction == "left" ? 252 : 253), 2, 
loc,
+                                       "Possible unintended reference 
comparison; to get a value comparison, " +
+                                       "cast the " + direction + " hand side 
to type " + type_name + ".");
+               }
+
                public override Expression DoResolve (EmitContext ec)
                {
                        if ((oper == Operator.Subtraction) && (left is 
ParenthesizedExpression)) {

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

Reply via email to