Implement check_assignment_to_expression in lvalue_check_c class.
authorConti Manuele <conti.ma@alice.it>
Wed, 18 Apr 2012 14:19:40 +0200
changeset 524 52b18b3c7490
parent 523 773303b7f31f
child 525 77bff42a025e
Implement check_assignment_to_expression in lvalue_check_c class.
stage3/lvalue_check.cc
--- a/stage3/lvalue_check.cc	Wed Apr 18 15:44:00 2012 +0100
+++ b/stage3/lvalue_check.cc	Wed Apr 18 14:19:40 2012 +0200
@@ -148,10 +148,31 @@
 
 /*  No assigning values to expressions. */
 void lvalue_check_c::check_assignment_to_expression(symbol_c *lvalue) {
-	/* TODO: check whether the lvalue is an expresion! */
 	/* This may occur in function invocations, when passing values (possibly an expression) to one 
 	 * of the function's OUTPUT or IN_OUT parameters.
 	 */
+	/* This may occur in function invocations, when passing values (possibly an expression) to one
+	 * of the function's OUTPUT or IN_OUT parameters.
+	 */
+	if ( (typeid( *lvalue ) == typeid( or_expression_c     )) ||
+	     (typeid( *lvalue ) == typeid( xor_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( and_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( equ_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( notequ_expression_c )) ||
+	     (typeid( *lvalue ) == typeid( lt_expression_c     )) ||
+	     (typeid( *lvalue ) == typeid( gt_expression_c     )) ||
+	     (typeid( *lvalue ) == typeid( le_expression_c     )) ||
+	     (typeid( *lvalue ) == typeid( ge_expression_c     )) ||
+	     (typeid( *lvalue ) == typeid( add_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( sub_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( mul_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( div_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( mod_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( power_expression_c  )) ||
+	     (typeid( *lvalue ) == typeid( neg_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( not_expression_c    )) ||
+	     (typeid( *lvalue ) == typeid( function_invocation_c)))
+		STAGE3_ERROR(0, lvalue, lvalue, "Assignment an expression to OUT or IN_OUT params is not be allowed.");
 }