Author: raja
Date: 2006-01-18 04:45:44 -0500 (Wed, 18 Jan 2006)
New Revision: 55713
Modified:
trunk/mcs/errors/known-issues-gmcs
trunk/mcs/gmcs/
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/assign.cs
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/gmcs/doc.cs
trunk/mcs/gmcs/ecore.cs
trunk/mcs/gmcs/expression.cs
Log:
*** merged revisions from mcs: 55631, 55676
Modified: trunk/mcs/errors/known-issues-gmcs
===================================================================
--- trunk/mcs/errors/known-issues-gmcs 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/errors/known-issues-gmcs 2006-01-18 09:45:44 UTC (rev 55713)
@@ -11,8 +11,6 @@
# csXXXX.cs NO ERROR : error test case doesn't report any error. An
exception is considered
# as NO ERROR and CS5001 is automatically ignored.
-cs0201-2.cs
-cs0201-3.cs
cs0229-2.cs
cs0229.cs NO ERROR
cs0231-2.cs
@@ -44,8 +42,6 @@
cs1540-5.cs NO ERROR # new in GMCS
cs1586.cs
cs1641.cs
-cs1654-2.cs NO ERROR
-cs1654.cs NO ERROR
cs1667-3.cs
cs1667-4.cs
cs1667-5.cs
Property changes on: trunk/mcs/gmcs
___________________________________________________________________
Name: gmcs
- Latest GMCS merging status:
- merged everything until r55462 (on 2006-01-13).
- not merging r49122, ie. we're keeping r48609 and r48610; see #75925.
- r37007 will never be merged; it's a mcs-only change.
- r43124 doesn't work in GMCS; not merged yet.
+ Latest GMCS merging status:
- merged everything until r55676 (on 2006-01-18).
- not merging r49122, ie. we're keeping r48609 and r48610; see #75925.
- r37007 will never be merged; it's a mcs-only change.
- r43124 doesn't work in GMCS; not merged yet.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/ChangeLog 2006-01-18 09:45:44 UTC (rev 55713)
@@ -1,3 +1,40 @@
+2006-01-17 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #76824.
+ * cs-parser.jay (statement_expression): Don't list out the
+ individual statement-expressions. Convert syntax error into
+ CS0201 check.
+
+2006-01-16 Raja R Harinath <[EMAIL PROTECTED]>
+
+ Fix #76874.
+ * ecore.cs (MemberAccess.CheckIntermediateModification): Remove.
+ (UnboxCast.DoResolveLValue): New. Move CS0445 check from
+ CheckIntermediateModification.
+ (FieldExpr.DoResolve): Add new two-argument version that
+ allows us to resolve the InstanceExpression as an lvalue.
+ The one-argument variant is now just a wrapper.
+ (FieldExpr.DoResolveLValue): Use two-argument DoResolve.
+ Resolve the lhs as an lvalue if the it has a value type.
+ (FieldExpr.AssignToReadonly): Move CS1648 and CS1650 checks
+ from Assign.DoResolve.
+ (PropertyExpr.InstanceResolve): Allow InstanceExpression to be
+ resolved as an lvalue.
+ (PropertyExpr.DoResolve): Update.
+ (PropertyExpr.DoResolveLValue): Resolve the lhs as an lvalue if it
+ has a value type. Move CS1612 check here from
+ CheckIntermediateModification.
+ * assign.cs (Assign.DoResolve): Remove CS1648 and CS1650 checks.
+ * expression.cs (EmptyExpression.OutAccess): New. Used as the
+ 'right_side' of a ResolveLValue on an 'out' argument.
+ (EmptyExpression.LValueMemberAccess): New. Used as the
+ 'right_side' of a propagated ResolveLValue on a value type.
+ (LocalVariableReference.DoResolveBase): Recognize
+ EmptyExpression.OutAccess and EmptyExpression.LValueMemberAccess.
+ Add CS1654 check.
+ (Argument.Resolve): Use EmptyExpression.OutAccess rather than
+ EmptyExpression.Null.
+
2006-01-16 Atsushi Enomoto <[EMAIL PROTECTED]>
* typemanager.cs : added IsGenericParameter(). In gmcs it returns
Modified: trunk/mcs/gmcs/assign.cs
===================================================================
--- trunk/mcs/gmcs/assign.cs 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/assign.cs 2006-01-18 09:45:44 UTC (rev 55713)
@@ -400,21 +400,6 @@
}
}
- FieldExpr field_exp = target as FieldExpr;
- if (field_exp != null &&
field_exp.DeclaringType.IsValueType && !ec.IsConstructor &&
!ec.IsFieldInitializer) {
- field_exp = field_exp.InstanceExpression as
FieldExpr;
- if (field_exp != null &&
field_exp.FieldInfo.IsInitOnly) {
- if (field_exp.IsStatic) {
- Report.Error (1650, loc,
"Fields of static readonly field `{0}' cannot be assigned to (except in a
static constructor or a variable initializer)",
-
field_exp.GetSignatureForError ());
- } else {
- Report.Error (1648, loc,
"Members of readonly field `{0}' cannot be modified (except in a constructor or
a variable initializer)",
-
field_exp.GetSignatureForError ());
- }
- return null;
- }
- }
-
if (!(target is IAssignMethod) && (target.eclass !=
ExprClass.EventAccess)) {
Report.Error (131, loc,
"Left hand of an assignment must
be a variable, " +
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/cs-parser.jay 2006-01-18 09:45:44 UTC (rev 55713)
@@ -4240,10 +4240,7 @@
;
expression_statement
- : statement_expression SEMICOLON
- {
- $$ = $1;
- }
+ : statement_expression SEMICOLON { $$ = $1; }
;
//
@@ -4251,14 +4248,18 @@
// because statement_expression is used for example in for_statement
//
statement_expression
- : invocation_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | object_creation_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | assignment_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | post_increment_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | post_decrement_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | pre_increment_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | pre_decrement_expression { $$ = new StatementExpression
((ExpressionStatement) $1); }
- | error {
+ : expression
+ {
+ Expression expr = (Expression) $1;
+ ExpressionStatement s = expr as ExpressionStatement;
+ if (s == null) {
+ Report.Error (201, expr.Location, "Only assignment,
call, increment, decrement, and new object expressions can be used as a
statement");
+ $$ = null;
+ }
+ $$ = new StatementExpression (s);
+ }
+ | error
+ {
Report.Error (1002, GetLocation ($1), "Expecting `;'");
$$ = null;
}
@@ -5273,6 +5274,7 @@
public void parse ()
{
+ int errors = Report.Errors;
try {
if (yacc_verbose_flag > 1)
yyparse (lexer, new yydebug.yyDebugSimple ());
@@ -5285,7 +5287,8 @@
// Removed for production use, use parser verbose to get the
output.
//
// Console.WriteLine (e);
- Report.Error (-25, lexer.Location, "Parsing error");
+ if (Report.Errors == errors)
+ Report.Error (-25, lexer.Location, "Parsing error");
if (yacc_verbose_flag > 0)
Console.WriteLine (e);
}
Modified: trunk/mcs/gmcs/doc.cs
===================================================================
--- trunk/mcs/gmcs/doc.cs 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/doc.cs 2006-01-18 09:45:44 UTC (rev 55713)
@@ -30,8 +30,16 @@
//
// Support class for XML documentation.
//
- public static class DocUtil
+#if NET_2_0
+ static
+#else
+ abstract
+#endif
+ public class DocUtil
{
+#if !NET_2_0
+ private DocUtil () {}
+#endif
// TypeContainer
//
Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/ecore.cs 2006-01-18 09:45:44 UTC (rev 55713)
@@ -1523,6 +1523,13 @@
return this;
}
+ public override Expression DoResolveLValue (EmitContext ec,
Expression right_side)
+ {
+ if (right_side == EmptyExpression.LValueMemberAccess)
+ Report.Error (445, loc, "Cannot modify the
result of an unboxing conversion");
+ return base.DoResolveLValue (ec, right_side);
+ }
+
public override void Emit (EmitContext ec)
{
Type t = type;
@@ -2629,25 +2636,6 @@
"with an instance reference, qualify it
with a type name instead", name);
}
- protected bool CheckIntermediateModification ()
- {
- if (!InstanceExpression.Type.IsValueType)
- return true;
-
- if (InstanceExpression is UnboxCast) {
- Report.Error (445, loc, "Cannot modify the
result of an unboxing conversion");
- return false;
- }
-
- if (!(InstanceExpression is IMemoryLocation)) {
- Report.Error (1612, loc, "Cannot modify the
return value of `{0}' because it is not a variable",
- InstanceExpression.GetSignatureForError
());
- return false;
- }
-
- return true;
- }
-
// TODO: possible optimalization
// Cache resolved constant result in FieldBuilder <->
expression map
public virtual Expression ResolveMemberAccess (EmitContext ec,
Expression left, Location loc,
@@ -3045,6 +3033,11 @@
override public Expression DoResolve (EmitContext ec)
{
+ return DoResolve (ec, false);
+ }
+
+ Expression DoResolve (EmitContext ec, bool lvalue_instance)
+ {
if (ec.InRefOutArgumentResolving &&
FieldInfo.IsInitOnly && !ec.IsConstructor && FieldInfo.FieldType.IsValueType) {
if (FieldInfo.FieldType is TypeBuilder) {
if (FieldInfo.IsStatic)
@@ -3077,8 +3070,17 @@
// Resolve the field's instance expression
while flow analysis is turned
// off: when accessing a field "a.b", we must
check whether the field
// "a.b" is initialized, not whether the whole
struct "a" is initialized.
- InstanceExpression = InstanceExpression.Resolve
(
- ec, ResolveFlags.VariableOrValue |
ResolveFlags.DisableFlowAnalysis);
+
+ if (lvalue_instance) {
+ bool old_do_flow_analysis =
ec.DoFlowAnalysis;
+ ec.DoFlowAnalysis = false;
+ InstanceExpression =
InstanceExpression.ResolveLValue (ec, EmptyExpression.LValueMemberAccess, loc);
+ ec.DoFlowAnalysis =
old_do_flow_analysis;
+ } else {
+ ResolveFlags rf =
ResolveFlags.VariableOrValue | ResolveFlags.DisableFlowAnalysis;
+ InstanceExpression =
InstanceExpression.Resolve (ec, rf);
+ }
+
if (InstanceExpression == null)
return null;
}
@@ -3124,16 +3126,32 @@
return this;
}
- void Report_AssignToReadonly (bool is_instance)
+ void Report_AssignToReadonly (Expression right_side)
{
+ int code;
string msg;
-
- if (is_instance)
+ bool need_error_sig = false;
+ if (right_side == EmptyExpression.LValueMemberAccess) {
+ if (IsStatic) {
+ code = 1650;
+ msg = "Fields of static readonly field
`{0}' cannot be assigned to (except in a static constructor or a variable
initializer)";
+ } else {
+ code = 1648;
+ msg = "Members of readonly field `{0}'
cannot be modified (except in a constructor or a variable initializer)";
+ }
+ need_error_sig = true;
+ } else if (IsStatic) {
+ code = 198;
+ msg = "A static readonly field cannot be
assigned to (except in a static constructor or a variable initializer)";
+ } else {
+ code = 191;
msg = "A readonly field cannot be assigned to
(except in a constructor or a variable initializer)";
+ }
+
+ if (need_error_sig)
+ Report.Error (code, loc, msg,
GetSignatureForError ());
else
- msg = "A static readonly field cannot be
assigned to (except in a static constructor or a variable initializer)";
-
- Report.Error (is_instance ? 191 : 198, loc, msg);
+ Report.Error (code, loc, msg);
}
override public Expression DoResolveLValue (EmitContext ec,
Expression right_side)
@@ -3142,14 +3160,13 @@
if ((var != null) && (var.VariableInfo != null))
var.VariableInfo.SetFieldAssigned (ec,
FieldInfo.Name);
- Expression e = DoResolve (ec);
+ bool lvalue_instance = !FieldInfo.IsStatic &&
FieldInfo.DeclaringType.IsValueType;
+ Expression e = DoResolve (ec, lvalue_instance);
+
if (e == null)
return null;
- if (!FieldInfo.IsStatic &&
!CheckIntermediateModification ())
- return null;
-
FieldBase fb = TypeManager.GetField (FieldInfo);
if (fb != null)
fb.SetAssigned ();
@@ -3163,7 +3180,7 @@
if (ec.IsConstructor){
if (IsStatic && !ec.IsStatic)
- Report_AssignToReadonly (false);
+ Report_AssignToReadonly (right_side);
Type ctype;
if (ec.TypeContainer.CurrentType != null)
@@ -3175,7 +3192,7 @@
return this;
}
- Report_AssignToReadonly (!IsStatic);
+ Report_AssignToReadonly (right_side);
return null;
}
@@ -3275,7 +3292,7 @@
prepared = prepare_for_load;
if (is_readonly && !ec.IsConstructor){
- Report_AssignToReadonly (!is_static);
+ Report_AssignToReadonly (source);
return;
}
@@ -3516,7 +3533,7 @@
}
}
- bool InstanceResolve (EmitContext ec, bool must_do_cs1540_check)
+ bool InstanceResolve (EmitContext ec, bool lvalue_instance,
bool must_do_cs1540_check)
{
if (is_static) {
InstanceExpression = null;
@@ -3528,7 +3545,10 @@
return false;
}
- InstanceExpression = InstanceExpression.DoResolve (ec);
+ if (lvalue_instance)
+ InstanceExpression =
InstanceExpression.ResolveLValue (ec, EmptyExpression.LValueMemberAccess, loc);
+ else
+ InstanceExpression =
InstanceExpression.DoResolve (ec);
if (InstanceExpression == null)
return false;
@@ -3608,7 +3628,7 @@
return null;
}
- if (!InstanceResolve (ec, must_do_cs1540_check))
+ if (!InstanceResolve (ec, false, must_do_cs1540_check))
return null;
//
@@ -3640,9 +3660,13 @@
//
if (getter == null)
return null;
-
- Report.Error (200, loc, " Property or indexer
`{0}' cannot be assigned to (it is read only)",
- TypeManager.GetFullNameSignature
(PropertyInfo));
+
+ if (right_side ==
EmptyExpression.LValueMemberAccess)
+ Report.Error (1612, loc, "Cannot modify
the return value of `{0}' because it is not a variable",
+ GetSignatureForError ());
+ else
+ Report.Error (200, loc, "Property or
indexer `{0}' cannot be assigned to (it is read only)",
+ GetSignatureForError ());
return null;
}
@@ -3664,7 +3688,7 @@
return null;
}
- if (!InstanceResolve (ec, must_do_cs1540_check))
+ if (!InstanceResolve (ec,
PropertyInfo.DeclaringType.IsValueType, must_do_cs1540_check))
return null;
//
@@ -3675,12 +3699,6 @@
return null;
}
- //
- // Check that we are not making changes to a temporary
memory location
- //
- if (InstanceExpression != null &&
!CheckIntermediateModification ())
- return null;
-
return this;
}
Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs 2006-01-18 09:09:41 UTC (rev 55712)
+++ trunk/mcs/gmcs/expression.cs 2006-01-18 09:45:44 UTC (rev 55713)
@@ -3489,7 +3489,7 @@
local_info = Block.GetLocalInfo (Name);
// is out param
- if (lvalue_right_side == EmptyExpression.Null)
+ if (lvalue_right_side ==
EmptyExpression.OutAccess)
local_info.Used = true;
is_readonly = local_info.ReadOnly;
@@ -3500,9 +3500,12 @@
VariableInfo variable_info = local_info.VariableInfo;
if (lvalue_right_side != null){
if (is_readonly){
- if (lvalue_right_side is
LocalVariableReference || lvalue_right_side == EmptyExpression.Null)
+ if (lvalue_right_side is
LocalVariableReference || lvalue_right_side == EmptyExpression.OutAccess)
Report.Error (1657, loc,
"Cannot pass `{0}' as a ref or out argument because it is a `{1}'",
Name,
local_info.GetReadOnlyContext ());
+ else if (lvalue_right_side ==
EmptyExpression.LValueMemberAccess)
+ Report.Error (1654, loc,
"Cannot assign to members of `{0}' because it is a `{1}'",
+ Name,
local_info.GetReadOnlyContext ());
else
Report.Error (1656, loc,
"Cannot assign to `{0}' because it is a `{1}'",
Name,
local_info.GetReadOnlyContext ());
@@ -4072,7 +4075,7 @@
Error_LValueRequired (loc);
} else if (ArgType == AType.Out) {
ec.InRefOutArgumentResolving = true;
- Expr = Expr.DoResolveLValue (ec,
EmptyExpression.Null);
+ Expr = Expr.DoResolveLValue (ec,
EmptyExpression.OutAccess);
ec.InRefOutArgumentResolving = false;
if (Expr == null)
@@ -8538,6 +8541,9 @@
public class EmptyExpression : Expression {
public static readonly EmptyExpression Null = new
EmptyExpression ();
+ public static readonly EmptyExpression OutAccess = new
EmptyExpression ();
+ public static readonly EmptyExpression LValueMemberAccess = new
EmptyExpression ();
+
static EmptyExpression temp = new EmptyExpression ();
public static EmptyExpression Grab ()
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches