Fix data type check array subscript field.
authorManuele Conti <conti.ma@alice.it>
Wed, 09 May 2012 20:05:57 +0200
changeset 549 af9517cad953
parent 548 7cc08964e0a7
child 550 322f063daa9f
Fix data type check array subscript field.
stage3/print_datatypes_error.cc
stage3/print_datatypes_error.hh
--- a/stage3/print_datatypes_error.cc	Wed May 09 23:04:03 2012 +0100
+++ b/stage3/print_datatypes_error.cc	Wed May 09 20:05:57 2012 +0200
@@ -591,8 +591,13 @@
 
 /* subscript_list ',' subscript */
 // SYM_LIST(subscript_list_c)
-/* NOTE: we inherit from iterator visitor, so we do not need to implement this method... */
-// void *print_datatypes_error_c::visit(subscript_list_c *symbol)
+void *print_datatypes_error_c::visit(subscript_list_c *symbol) {
+	for (int i = 0; i < symbol->n; i++) {
+		if (NULL == symbol->elements[i]->datatype)
+			STAGE3_ERROR(0, symbol, symbol, "Invalid data type for array subscript field.");
+	}
+	return NULL;
+}
 
 
 /*  record_variable '.' field_selector */
--- a/stage3/print_datatypes_error.hh	Wed May 09 23:04:03 2012 +0100
+++ b/stage3/print_datatypes_error.hh	Wed May 09 20:05:57 2012 +0200
@@ -167,6 +167,7 @@
     /* B 1.4.2 - Multi-element variables */
     /*************************************/
     void *visit(array_variable_c *symbol);
+    void *visit(subscript_list_c *symbol);
     void *visit(structured_variable_c *symbol);
 
     /******************************************/