diff -r 67d8b07bac22 -r 587884880be6 stage3/print_datatypes_error.cc --- a/stage3/print_datatypes_error.cc Mon Feb 27 11:44:03 2012 +0000 +++ b/stage3/print_datatypes_error.cc Thu Mar 01 10:28:27 2012 +0000 @@ -55,7 +55,7 @@ #define STAGE3_ERROR(error_level, symbol1, symbol2, ...) { \ if (current_display_error_level >= error_level) { \ - fprintf(stderr, "%s:%d-%d..%d-%d: error : ", \ + fprintf(stderr, "%s:%d-%d..%d-%d: error: ", \ FIRST_(symbol1,symbol2)->first_file, FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column,\ LAST_(symbol1,symbol2) ->last_line, LAST_(symbol1,symbol2) ->last_column);\ fprintf(stderr, __VA_ARGS__); \ @@ -66,11 +66,22 @@ } +#define STAGE3_WARNING(symbol1, symbol2, ...) { \ + fprintf(stderr, "%s:%d-%d..%d-%d: warning: ", \ + FIRST_(symbol1,symbol2)->first_file, FIRST_(symbol1,symbol2)->first_line, FIRST_(symbol1,symbol2)->first_column,\ + LAST_(symbol1,symbol2) ->last_line, LAST_(symbol1,symbol2) ->last_column);\ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + warning_found = true; \ +} + + /* set to 1 to see debug info during execution */ static int debug = 0; print_datatypes_error_c::print_datatypes_error_c(symbol_c *ignore) { error_found = false; + warning_found = false; current_display_error_level = error_level_default; } @@ -93,6 +104,15 @@ +void print_datatypes_error_c::check_used_operation_status(symbol_c *symbol, symbol_c *left, symbol_c *right, const struct widen_entry widen_table[]) { + /* find a compatible entry in the widening table */ + for (int k = 0; NULL != widen_table[k].left; k++) + if (is_type_equal(left, widen_table[k].left) && is_type_equal(right, widen_table[k].right)) + if (widen_entry::deprecated == widen_table[k].status) + STAGE3_WARNING(symbol, symbol, "Deprecated operation."); +} + + /* typedef struct { symbol_c *function_name, @@ -894,6 +914,7 @@ } void *print_datatypes_error_c::visit(ADD_operator_c *symbol) { + /* TODO: print warning messages for deprecated operations! */ if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'ADD' operator."); @@ -901,6 +922,7 @@ } void *print_datatypes_error_c::visit(SUB_operator_c *symbol) { + /* TODO: print warning messages for deprecated operations! */ if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'SUB' operator."); @@ -908,6 +930,7 @@ } void *print_datatypes_error_c::visit(MUL_operator_c *symbol) { + /* TODO: print warning messages for deprecated operations! */ if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'MUL' operator."); @@ -915,6 +938,7 @@ } void *print_datatypes_error_c::visit(DIV_operator_c *symbol) { + /* TODO: print warning messages for deprecated operations! */ if ((symbol->candidate_datatypes.size() == 0) && (il_operand->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for 'DIV' operator."); @@ -1113,7 +1137,8 @@ (symbol->l_exp->candidate_datatypes.size() > 0) && (symbol->r_exp->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '+' expression."); - + + check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_ADD_table); return NULL; } @@ -1126,6 +1151,7 @@ (symbol->l_exp->candidate_datatypes.size() > 0) && (symbol->r_exp->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '-' expression."); + check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_SUB_table); return NULL; } @@ -1136,6 +1162,7 @@ (symbol->l_exp->candidate_datatypes.size() > 0) && (symbol->r_exp->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '*' expression."); + check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_MUL_table); return NULL; } @@ -1146,6 +1173,7 @@ (symbol->l_exp->candidate_datatypes.size() > 0) && (symbol->r_exp->candidate_datatypes.size() > 0)) STAGE3_ERROR(0, symbol, symbol, "Data type mismatch for '/' expression."); + check_used_operation_status(symbol, symbol->l_exp->datatype,symbol->r_exp->datatype, widen_DIV_table); return NULL; }