stage3/print_datatypes_error.cc
changeset 848 db78824cec23
parent 847 079ab7d4b728
child 873 dea39ef02847
equal deleted inserted replaced
847:079ab7d4b728 848:db78824cec23
   158 		fcall_data.formal_operand_list->accept(*this);
   158 		fcall_data.formal_operand_list->accept(*this);
   159 		if (NULL != f_decl) {
   159 		if (NULL != f_decl) {
   160 			function_param_iterator_c fp_iterator(f_decl);
   160 			function_param_iterator_c fp_iterator(f_decl);
   161 			while ((param_name = fcp_iterator.next_f()) != NULL) {
   161 			while ((param_name = fcp_iterator.next_f()) != NULL) {
   162 				param_value = fcp_iterator.get_current_value();
   162 				param_value = fcp_iterator.get_current_value();
   163 
   163 				
   164 				/* Check if there are duplicate parameter values */
   164 				/* Check if there are duplicate parameter values */
   165 				if(fcp_iterator.search_f(param_name) != param_value) {
   165 				if(fcp_iterator.search_f(param_name) != param_value) {
   166 					function_invocation_error = true;
   166 					function_invocation_error = true;
   167 					STAGE3_ERROR(0, param_name, param_name, "Duplicate parameter '%s' when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   167 					STAGE3_ERROR(0, param_name, param_name, "Duplicate parameter '%s' when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   168 					continue; /* jump to next parameter */
   168 					continue; /* jump to next parameter */
   193 						STAGE3_ERROR(0, param_name, param_name, "Invalid assignment syntax '=>' used for parameter '%s', when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   193 						STAGE3_ERROR(0, param_name, param_name, "Invalid assignment syntax '=>' used for parameter '%s', when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   194 						continue; /* jump to next parameter */
   194 						continue; /* jump to next parameter */
   195 					}
   195 					}
   196 				} else ERROR;
   196 				} else ERROR;
   197 
   197 
   198 				if (NULL == param_value->datatype) {
   198 				if (!get_datatype_info_c::is_type_valid(param_value->datatype)) {
   199 					function_invocation_error = true;
   199 					function_invocation_error = true;
   200 					STAGE3_ERROR(0, param_value, param_value, "Data type incompatibility between parameter '%s' and value being passed, when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   200 					STAGE3_ERROR(0, param_value, param_value, "Data type incompatibility between parameter '%s' and value being passed, when invoking %s '%s'", ((identifier_c *)param_name)->value, POU_str, ((identifier_c *)fcall_data.function_name)->value);
   201 					continue; /* jump to next parameter */
   201 					continue; /* jump to next parameter */
   202 				}
   202 				}
   203 			}
   203 			}
   314 	/* NOTE: The error_level currently being used for errors in variables/constants etc... is rather high.
   314 	/* NOTE: The error_level currently being used for errors in variables/constants etc... is rather high.
   315 	 *       However, in the case of an implicit FB call, if the datatype of the operand == NULL, this may be
   315 	 *       However, in the case of an implicit FB call, if the datatype of the operand == NULL, this may be
   316 	 *       the __only__ indication of an error! So we test it here again, to make sure thtis error will really
   316 	 *       the __only__ indication of an error! So we test it here again, to make sure thtis error will really
   317 	 *       be printed out!
   317 	 *       be printed out!
   318 	 */
   318 	 */
   319 	if (NULL == il_operand->datatype) {
   319 	if (!get_datatype_info_c::is_type_valid(il_operand->datatype)) {
   320 		/* Note: the case of (NULL == fb_declaration) was already caught above! */
   320 		/* Note: the case of (NULL == fb_declaration) was already caught above! */
   321 // 		if (NULL != fb_declaration) {
   321 // 		if (NULL != fb_declaration) {
   322 			STAGE3_ERROR(0, il_operator, il_operator, "Invalid FB call: Datatype incompatibility between the FB's '%s' parameter and value being passed, or paramater '%s' is not a 'VAR_INPUT' parameter.", param_name, param_name);
   322 			STAGE3_ERROR(0, il_operator, il_operator, "Invalid FB call: Datatype incompatibility between the FB's '%s' parameter and value being passed, or paramater '%s' is not a 'VAR_INPUT' parameter.", param_name, param_name);
   323 			return NULL;
   323 			return NULL;
   324 // 		}
   324 // 		}
   335 /* B 1.2.1 - Numeric Literals */
   335 /* B 1.2.1 - Numeric Literals */
   336 /******************************/
   336 /******************************/
   337 void *print_datatypes_error_c::visit(real_c *symbol) {
   337 void *print_datatypes_error_c::visit(real_c *symbol) {
   338 	if (symbol->candidate_datatypes.size() == 0) {
   338 	if (symbol->candidate_datatypes.size() == 0) {
   339 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type.");
   339 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type.");
   340 	} else if (NULL == symbol->datatype) {
   340 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   341 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   341 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   342 	}
   342 	}
   343 	return NULL;
   343 	return NULL;
   344 }
   344 }
   345 
   345 
   346 void *print_datatypes_error_c::visit(integer_c *symbol) {
   346 void *print_datatypes_error_c::visit(integer_c *symbol) {
   347 	if (symbol->candidate_datatypes.size() == 0) {
   347 	if (symbol->candidate_datatypes.size() == 0) {
   348 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   348 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   349 	} else if (NULL == symbol->datatype) {
   349 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   350 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   350 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   351 	}
   351 	}
   352 	return NULL;
   352 	return NULL;
   353 }
   353 }
   354 
   354 
   355 void *print_datatypes_error_c::visit(neg_real_c *symbol) {
   355 void *print_datatypes_error_c::visit(neg_real_c *symbol) {
   356 	if (symbol->candidate_datatypes.size() == 0) {
   356 	if (symbol->candidate_datatypes.size() == 0) {
   357 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type.");
   357 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_REAL data type.");
   358 	} else if (NULL == symbol->datatype) {
   358 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   359 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   359 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   360 	}
   360 	}
   361 	return NULL;
   361 	return NULL;
   362 }
   362 }
   363 
   363 
   364 void *print_datatypes_error_c::visit(neg_integer_c *symbol) {
   364 void *print_datatypes_error_c::visit(neg_integer_c *symbol) {
   365 	if (symbol->candidate_datatypes.size() == 0) {
   365 	if (symbol->candidate_datatypes.size() == 0) {
   366 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   366 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   367 	} else if (NULL == symbol->datatype) {
   367 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   368 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   368 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   369 	}
   369 	}
   370 	return NULL;
   370 	return NULL;
   371 }
   371 }
   372 
   372 
   373 void *print_datatypes_error_c::visit(binary_integer_c *symbol) {
   373 void *print_datatypes_error_c::visit(binary_integer_c *symbol) {
   374 	if (symbol->candidate_datatypes.size() == 0) {
   374 	if (symbol->candidate_datatypes.size() == 0) {
   375 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   375 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   376 	} else if (NULL == symbol->datatype) {
   376 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   377 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   377 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   378 	}
   378 	}
   379 	return NULL;
   379 	return NULL;
   380 }
   380 }
   381 
   381 
   382 void *print_datatypes_error_c::visit(octal_integer_c *symbol) {
   382 void *print_datatypes_error_c::visit(octal_integer_c *symbol) {
   383 	if (symbol->candidate_datatypes.size() == 0) {
   383 	if (symbol->candidate_datatypes.size() == 0) {
   384 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   384 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   385 	} else if (NULL == symbol->datatype) {
   385 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   386 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   386 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   387 	}
   387 	}
   388 	return NULL;
   388 	return NULL;
   389 }
   389 }
   390 
   390 
   391 void *print_datatypes_error_c::visit(hex_integer_c *symbol) {
   391 void *print_datatypes_error_c::visit(hex_integer_c *symbol) {
   392 	if (symbol->candidate_datatypes.size() == 0) {
   392 	if (symbol->candidate_datatypes.size() == 0) {
   393 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   393 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for ANY_INT data type.");
   394 	} else if (NULL == symbol->datatype) {
   394 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   395 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   395 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   396 	}
   396 	}
   397 	return NULL;
   397 	return NULL;
   398 }
   398 }
   399 
   399 
   400 void *print_datatypes_error_c::visit(integer_literal_c *symbol) {
   400 void *print_datatypes_error_c::visit(integer_literal_c *symbol) {
   401 	if (symbol->candidate_datatypes.size() == 0) {
   401 	if (symbol->candidate_datatypes.size() == 0) {
   402 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   402 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   403 	} else if (NULL == symbol->datatype) {
   403 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   404 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   404 		STAGE3_ERROR(4, symbol, symbol, "ANY_INT data type not valid in this location.");
   405 	}
   405 	}
   406 	return NULL;
   406 	return NULL;
   407 }
   407 }
   408 
   408 
   409 void *print_datatypes_error_c::visit(real_literal_c *symbol) {
   409 void *print_datatypes_error_c::visit(real_literal_c *symbol) {
   410 	if (symbol->candidate_datatypes.size() == 0) {
   410 	if (symbol->candidate_datatypes.size() == 0) {
   411 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   411 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   412 	} else if (NULL == symbol->datatype) {
   412 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   413 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   413 		STAGE3_ERROR(4, symbol, symbol, "ANY_REAL data type not valid in this location.");
   414 	}
   414 	}
   415 	return NULL;
   415 	return NULL;
   416 }
   416 }
   417 
   417 
   418 void *print_datatypes_error_c::visit(bit_string_literal_c *symbol) {
   418 void *print_datatypes_error_c::visit(bit_string_literal_c *symbol) {
   419 	if (symbol->candidate_datatypes.size() == 0) {
   419 	if (symbol->candidate_datatypes.size() == 0) {
   420 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   420 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   421 	} else if (NULL == symbol->datatype) {
   421 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   422 		STAGE3_ERROR(4, symbol, symbol, "ANY_BIT data type not valid in this location.");
   422 		STAGE3_ERROR(4, symbol, symbol, "ANY_BIT data type not valid in this location.");
   423 	}
   423 	}
   424 	return NULL;
   424 	return NULL;
   425 }
   425 }
   426 
   426 
   427 void *print_datatypes_error_c::visit(boolean_literal_c *symbol) {
   427 void *print_datatypes_error_c::visit(boolean_literal_c *symbol) {
   428 	if (symbol->candidate_datatypes.size() == 0) {
   428 	if (symbol->candidate_datatypes.size() == 0) {
   429 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   429 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for %s data type.", get_datatype_info_c::get_id_str(symbol->type));
   430 	} else if (NULL == symbol->datatype) {
   430 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   431 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   431 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   432 	}
   432 	}
   433 	return NULL;
   433 	return NULL;
   434 }
   434 }
   435 
   435 
   436 void *print_datatypes_error_c::visit(boolean_true_c *symbol) {
   436 void *print_datatypes_error_c::visit(boolean_true_c *symbol) {
   437 	if (symbol->candidate_datatypes.size() == 0) {
   437 	if (symbol->candidate_datatypes.size() == 0) {
   438 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type.");
   438 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type.");
   439 	} else if (NULL == symbol->datatype) {
   439 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   440 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   440 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   441 	}
   441 	}
   442 	return NULL;
   442 	return NULL;
   443 }
   443 }
   444 
   444 
   445 void *print_datatypes_error_c::visit(boolean_false_c *symbol) {
   445 void *print_datatypes_error_c::visit(boolean_false_c *symbol) {
   446 	if (symbol->candidate_datatypes.size() == 0) {
   446 	if (symbol->candidate_datatypes.size() == 0) {
   447 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type.");
   447 		STAGE3_ERROR(0, symbol, symbol, "Value is not valid for ANY_BOOL data type.");
   448 	} else if (NULL == symbol->datatype) {
   448 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   449 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   449 		STAGE3_ERROR(4, symbol, symbol, "ANY_BOOL data type not valid in this location.");
   450 	}
   450 	}
   451 	return NULL;
   451 	return NULL;
   452 }
   452 }
   453 
   453 
   455 /* B.1.2.2   Character Strings */
   455 /* B.1.2.2   Character Strings */
   456 /*******************************/
   456 /*******************************/
   457 void *print_datatypes_error_c::visit(double_byte_character_string_c *symbol) {
   457 void *print_datatypes_error_c::visit(double_byte_character_string_c *symbol) {
   458 	if (symbol->candidate_datatypes.size() == 0) {
   458 	if (symbol->candidate_datatypes.size() == 0) {
   459 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for WSTRING data type.");
   459 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for WSTRING data type.");
   460 	} else if (NULL == symbol->datatype) {
   460 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   461 		STAGE3_ERROR(4, symbol, symbol, "WSTRING data type not valid in this location.");
   461 		STAGE3_ERROR(4, symbol, symbol, "WSTRING data type not valid in this location.");
   462 	}
   462 	}
   463 	return NULL;
   463 	return NULL;
   464 }
   464 }
   465 
   465 
   466 void *print_datatypes_error_c::visit(single_byte_character_string_c *symbol) {
   466 void *print_datatypes_error_c::visit(single_byte_character_string_c *symbol) {
   467 	if (symbol->candidate_datatypes.size() == 0) {
   467 	if (symbol->candidate_datatypes.size() == 0) {
   468 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for STRING data type.");
   468 		STAGE3_ERROR(0, symbol, symbol, "Numerical value exceeds range for STRING data type.");
   469 	} else if (NULL == symbol->datatype) {
   469 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   470 		STAGE3_ERROR(4, symbol, symbol, "STRING data type not valid in this location.");
   470 		STAGE3_ERROR(4, symbol, symbol, "STRING data type not valid in this location.");
   471 	}
   471 	}
   472 	return NULL;
   472 	return NULL;
   473 }
   473 }
   474 
   474 
   479 /* B 1.2.3.1 - Duration */
   479 /* B 1.2.3.1 - Duration */
   480 /************************/
   480 /************************/
   481 void *print_datatypes_error_c::visit(duration_c *symbol) {
   481 void *print_datatypes_error_c::visit(duration_c *symbol) {
   482 	if (symbol->candidate_datatypes.size() == 0) {
   482 	if (symbol->candidate_datatypes.size() == 0) {
   483 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TIME data type.");
   483 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TIME data type.");
   484 	} else if (NULL == symbol->datatype) {
   484 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   485 		STAGE3_ERROR(4, symbol, symbol, "TIME data type not valid in this location.");
   485 		STAGE3_ERROR(4, symbol, symbol, "TIME data type not valid in this location.");
   486 	}
   486 	}
   487 	return NULL;
   487 	return NULL;
   488 }
   488 }
   489 
   489 
   491 /* B 1.2.3.2 - Time of day and Date */
   491 /* B 1.2.3.2 - Time of day and Date */
   492 /************************************/
   492 /************************************/
   493 void *print_datatypes_error_c::visit(time_of_day_c *symbol) {
   493 void *print_datatypes_error_c::visit(time_of_day_c *symbol) {
   494 	if (symbol->candidate_datatypes.size() == 0) {
   494 	if (symbol->candidate_datatypes.size() == 0) {
   495 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TOD data type.");
   495 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for TOD data type.");
   496 	} else if (NULL == symbol->datatype) {
   496 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   497 		STAGE3_ERROR(4, symbol, symbol, "TOD data type not valid in this location.");
   497 		STAGE3_ERROR(4, symbol, symbol, "TOD data type not valid in this location.");
   498 	}
   498 	}
   499 	return NULL;
   499 	return NULL;
   500 }
   500 }
   501 
   501 
   502 void *print_datatypes_error_c::visit(date_c *symbol) {
   502 void *print_datatypes_error_c::visit(date_c *symbol) {
   503 	if (symbol->candidate_datatypes.size() == 0) {
   503 	if (symbol->candidate_datatypes.size() == 0) {
   504 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DATE data type.");
   504 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DATE data type.");
   505 	} else if (NULL == symbol->datatype) {
   505 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   506 		STAGE3_ERROR(4, symbol, symbol, "DATE data type not valid in this location.");
   506 		STAGE3_ERROR(4, symbol, symbol, "DATE data type not valid in this location.");
   507 	}
   507 	}
   508 	return NULL;
   508 	return NULL;
   509 }
   509 }
   510 
   510 
   511 void *print_datatypes_error_c::visit(date_and_time_c *symbol) {
   511 void *print_datatypes_error_c::visit(date_and_time_c *symbol) {
   512 	if (symbol->candidate_datatypes.size() == 0) {
   512 	if (symbol->candidate_datatypes.size() == 0) {
   513 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DT data type.");
   513 		STAGE3_ERROR(0, symbol, symbol, "Invalid syntax for DT data type.");
   514 	} else if (NULL == symbol->datatype) {
   514 	} else if (!get_datatype_info_c::is_type_valid(symbol->datatype)) {
   515 		STAGE3_ERROR(4, symbol, symbol, "DT data type not valid in this location.");
   515 		STAGE3_ERROR(4, symbol, symbol, "DT data type not valid in this location.");
   516 	}
   516 	}
   517 	return NULL;
   517 	return NULL;
   518 }
   518 }
   519 
   519 
   587 void *print_datatypes_error_c::visit(subscript_list_c *symbol) {
   587 void *print_datatypes_error_c::visit(subscript_list_c *symbol) {
   588 	for (int i = 0; i < symbol->n; i++) {
   588 	for (int i = 0; i < symbol->n; i++) {
   589 		int start_error_count = error_count;
   589 		int start_error_count = error_count;
   590 		symbol->elements[i]->accept(*this);
   590 		symbol->elements[i]->accept(*this);
   591 		/* The following error message will only get printed if the current_display_error_level is set higher than 0! */
   591 		/* The following error message will only get printed if the current_display_error_level is set higher than 0! */
   592 		if ((start_error_count == error_count) && (NULL == symbol->elements[i]->datatype))
   592 		if ((start_error_count == error_count) && (!get_datatype_info_c::is_type_valid(symbol->elements[i]->datatype)))
   593 			STAGE3_ERROR(0, symbol, symbol, "Invalid data type for array subscript field.");
   593 			STAGE3_ERROR(0, symbol, symbol, "Invalid data type for array subscript field.");
   594 	}
   594 	}
   595 	return NULL;
   595 	return NULL;
   596 }
   596 }
   597 
   597 
   934 void *print_datatypes_error_c::print_binary_operator_errors(const char *il_operator, symbol_c *symbol, bool deprecated_operation) {
   934 void *print_datatypes_error_c::print_binary_operator_errors(const char *il_operator, symbol_c *symbol, bool deprecated_operation) {
   935 	if (NULL == il_operand) {
   935 	if (NULL == il_operand) {
   936 		STAGE3_ERROR(0, symbol, symbol, "Missing operand for %s operator.", il_operator);		// message (a)
   936 		STAGE3_ERROR(0, symbol, symbol, "Missing operand for %s operator.", il_operator);		// message (a)
   937 	} else if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) {
   937 	} else if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) {
   938 		STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '%s' operator.", il_operator);		// message (b)
   938 		STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '%s' operator.", il_operator);		// message (b)
   939 	} else if (NULL == symbol->datatype) {
   939 	} else if (NULL == symbol->datatype) {  // do NOT use !get_datatype_info_c::is_type_valid() here!
   940 		STAGE3_WARNING(symbol, symbol, "Result of '%s' operation is never used.", il_operator);		// message (c)
   940 		STAGE3_WARNING(symbol, symbol, "Result of '%s' operation is never used.", il_operator);		// message (c)
   941 	} else if (deprecated_operation)
   941 	} else if (deprecated_operation)
   942 		STAGE3_WARNING(symbol, symbol, "Deprecated operation for '%s' operator.", il_operator);		// message (d)
   942 		STAGE3_WARNING(symbol, symbol, "Deprecated operation for '%s' operator.", il_operator);		// message (d)
   943 	return NULL;
   943 	return NULL;
   944 }
   944 }
  1109 /* B 3.2.1 Assignment Statements */
  1109 /* B 3.2.1 Assignment Statements */
  1110 /*********************************/
  1110 /*********************************/
  1111 void *print_datatypes_error_c::visit(assignment_statement_c *symbol) {
  1111 void *print_datatypes_error_c::visit(assignment_statement_c *symbol) {
  1112 	symbol->l_exp->accept(*this);
  1112 	symbol->l_exp->accept(*this);
  1113 	symbol->r_exp->accept(*this);
  1113 	symbol->r_exp->accept(*this);
  1114 	if ((NULL == symbol->l_exp->datatype) &&
  1114 	if ((!get_datatype_info_c::is_type_valid(symbol->l_exp->datatype)) &&
  1115 	    (NULL == symbol->r_exp->datatype) &&
  1115 	    (!get_datatype_info_c::is_type_valid(symbol->r_exp->datatype)) &&
  1116 		(symbol->l_exp->candidate_datatypes.size() > 0)	&&
  1116 	    (symbol->l_exp->candidate_datatypes.size() > 0)	&&
  1117 		(symbol->r_exp->candidate_datatypes.size() > 0))
  1117 	    (symbol->r_exp->candidate_datatypes.size() > 0))
  1118 		STAGE3_ERROR(0, symbol, symbol, "Incompatible data types for ':=' operation.");
  1118 		STAGE3_ERROR(0, symbol, symbol, "Incompatible data types for ':=' operation.");
  1119 	return NULL;
  1119 	return NULL;
  1120 }
  1120 }
  1121 
  1121 
  1122 
  1122 
  1150 /* B 3.2.3 Selection Statements */
  1150 /* B 3.2.3 Selection Statements */
  1151 /********************************/
  1151 /********************************/
  1152 
  1152 
  1153 void *print_datatypes_error_c::visit(if_statement_c *symbol) {
  1153 void *print_datatypes_error_c::visit(if_statement_c *symbol) {
  1154 	symbol->expression->accept(*this);
  1154 	symbol->expression->accept(*this);
  1155 	if ((NULL == symbol->expression->datatype) &&
  1155 	if ((!get_datatype_info_c::is_type_valid(symbol->expression->datatype)) &&
  1156 		(symbol->expression->candidate_datatypes.size() > 0)) {
  1156 	    (symbol->expression->candidate_datatypes.size() > 0)) {
  1157 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'IF' condition.");
  1157 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'IF' condition.");
  1158 	}
  1158 	}
  1159 	if (NULL != symbol->statement_list)
  1159 	if (NULL != symbol->statement_list)
  1160 		symbol->statement_list->accept(*this);
  1160 		symbol->statement_list->accept(*this);
  1161 	if (NULL != symbol->elseif_statement_list)
  1161 	if (NULL != symbol->elseif_statement_list)
  1165 	return NULL;
  1165 	return NULL;
  1166 }
  1166 }
  1167 
  1167 
  1168 void *print_datatypes_error_c::visit(elseif_statement_c *symbol) {
  1168 void *print_datatypes_error_c::visit(elseif_statement_c *symbol) {
  1169 	symbol->expression->accept(*this);
  1169 	symbol->expression->accept(*this);
  1170 	if ((NULL == symbol->expression->datatype) &&
  1170 	if ((!get_datatype_info_c::is_type_valid(symbol->expression->datatype)) &&
  1171 		(symbol->expression->candidate_datatypes.size() > 0)) {
  1171 	    (symbol->expression->candidate_datatypes.size() > 0)) {
  1172 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'ELSIF' condition.");
  1172 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'ELSIF' condition.");
  1173 	}
  1173 	}
  1174 	if (NULL != symbol->statement_list)
  1174 	if (NULL != symbol->statement_list)
  1175 		symbol->statement_list->accept(*this);
  1175 		symbol->statement_list->accept(*this);
  1176 	return NULL;
  1176 	return NULL;
  1177 }
  1177 }
  1178 
  1178 
  1179 
  1179 
  1180 void *print_datatypes_error_c::visit(case_statement_c *symbol) {
  1180 void *print_datatypes_error_c::visit(case_statement_c *symbol) {
  1181 	symbol->expression->accept(*this);
  1181 	symbol->expression->accept(*this);
  1182 	if ((NULL == symbol->expression->datatype) &&
  1182 	if ((!get_datatype_info_c::is_type_valid(symbol->expression->datatype)) &&
  1183 		(symbol->expression->candidate_datatypes.size() > 0)) {
  1183 	    (symbol->expression->candidate_datatypes.size() > 0)) {
  1184 		STAGE3_ERROR(0, symbol, symbol, "'CASE' quantity not an integer or enumerated.");
  1184 		STAGE3_ERROR(0, symbol, symbol, "'CASE' quantity not an integer or enumerated.");
  1185 	}
  1185 	}
  1186 	symbol->case_element_list->accept(*this);
  1186 	symbol->case_element_list->accept(*this);
  1187 	if (NULL != symbol->statement_list)
  1187 	if (NULL != symbol->statement_list)
  1188 		symbol->statement_list->accept(*this);
  1188 		symbol->statement_list->accept(*this);
  1196 void *print_datatypes_error_c::visit(for_statement_c *symbol) {
  1196 void *print_datatypes_error_c::visit(for_statement_c *symbol) {
  1197 	symbol->control_variable->accept(*this);
  1197 	symbol->control_variable->accept(*this);
  1198 	symbol->beg_expression->accept(*this);
  1198 	symbol->beg_expression->accept(*this);
  1199 	symbol->end_expression->accept(*this);
  1199 	symbol->end_expression->accept(*this);
  1200 	/* Control variable */
  1200 	/* Control variable */
  1201 	if ((NULL == symbol->control_variable->datatype) &&
  1201 	if ((!get_datatype_info_c::is_type_valid(symbol->control_variable->datatype)) &&
  1202 		(symbol->control_variable->candidate_datatypes.size() > 0)) {
  1202 	    (symbol->control_variable->candidate_datatypes.size() > 0)) {
  1203 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' control variable.");
  1203 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' control variable.");
  1204 	}
  1204 	}
  1205 	/* BEG expression */
  1205 	/* BEG expression */
  1206 	if ((NULL == symbol->beg_expression->datatype) &&
  1206 	if ((!get_datatype_info_c::is_type_valid(symbol->beg_expression->datatype)) &&
  1207 		(symbol->beg_expression->candidate_datatypes.size() > 0)) {
  1207 	    (symbol->beg_expression->candidate_datatypes.size() > 0)) {
  1208 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' begin expression.");
  1208 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' begin expression.");
  1209 	}
  1209 	}
  1210 	/* END expression */
  1210 	/* END expression */
  1211 	if ((NULL == symbol->end_expression->datatype) &&
  1211 	if ((!get_datatype_info_c::is_type_valid(symbol->end_expression->datatype)) &&
  1212 		(symbol->end_expression->candidate_datatypes.size() > 0)) {
  1212 	    (symbol->end_expression->candidate_datatypes.size() > 0)) {
  1213 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' end expression.");
  1213 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' end expression.");
  1214 	}
  1214 	}
  1215 	/* BY expression */
  1215 	/* BY expression */
  1216 	if ((NULL != symbol->by_expression) &&
  1216 	if ((NULL != symbol->by_expression) &&
  1217 		(NULL == symbol->by_expression->datatype) &&
  1217 	    (!get_datatype_info_c::is_type_valid(symbol->by_expression->datatype)) &&
  1218 		(symbol->end_expression->candidate_datatypes.size() > 0)) {
  1218 	    (symbol->end_expression->candidate_datatypes.size() > 0)) {
  1219 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' by expression.");
  1219 		STAGE3_ERROR(0, symbol, symbol, "Invalid data type for 'FOR' by expression.");
  1220 	}
  1220 	}
  1221 	/* DO statement */
  1221 	/* DO statement */
  1222 	if (NULL != symbol->statement_list)
  1222 	if (NULL != symbol->statement_list)
  1223 		symbol->statement_list->accept(*this);
  1223 		symbol->statement_list->accept(*this);