# HG changeset patch # User laurent # Date 1321611797 -3600 # Node ID 9cf96d45853d82cbb87daa4c53db6c94b8ae32e7 # Parent 94b67e38188ac2e08cdc3f73c58926867d29e4f2 Fix bug when using enumerated type in equ_expression or notequ_expression diff -r 94b67e38188a -r 9cf96d45853d stage3/visit_expression_type.cc --- a/stage3/visit_expression_type.cc Wed Nov 16 17:48:22 2011 +0100 +++ b/stage3/visit_expression_type.cc Fri Nov 18 11:23:17 2011 +0100 @@ -440,6 +440,13 @@ return false; } +bool visit_expression_type_c::is_ANY_ELEMENTARY_OR_ENUMERATED_compatible(symbol_c *type_symbol) { + if (type_symbol == NULL) {return false;} + if (search_base_type.type_is_enumerated(type_symbol)) {return true;} + return is_ANY_ELEMENTARY_compatible(type_symbol); +} + + /* Determine the common data type between two data types. * If no common data type found, return NULL. * @@ -1785,7 +1792,7 @@ void *visit_expression_type_c::visit(equ_expression_c *symbol) { symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); - compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible, symbol->l_exp, symbol->r_exp); + compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_OR_ENUMERATED_compatible, symbol->l_exp, symbol->r_exp); return &search_expression_type_c::bool_type_name; } @@ -1793,7 +1800,7 @@ void *visit_expression_type_c::visit(notequ_expression_c *symbol) { symbol_c *left_type = base_type((symbol_c *)symbol->l_exp->accept(*this)); symbol_c *right_type = base_type((symbol_c *)symbol->r_exp->accept(*this)); - compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_compatible, symbol->l_exp, symbol->r_exp); + compute_expression(left_type, right_type, &visit_expression_type_c::is_ANY_ELEMENTARY_OR_ENUMERATED_compatible, symbol->l_exp, symbol->r_exp); return &search_expression_type_c::bool_type_name; } diff -r 94b67e38188a -r 9cf96d45853d stage3/visit_expression_type.hh --- a/stage3/visit_expression_type.hh Wed Nov 16 17:48:22 2011 +0100 +++ b/stage3/visit_expression_type.hh Fri Nov 18 11:23:17 2011 +0100 @@ -137,6 +137,8 @@ bool is_literal_real_type (symbol_c *type_symbol); bool is_literal_bool_type (symbol_c *type_symbol); + bool is_ANY_ELEMENTARY_OR_ENUMERATED_compatible (symbol_c *type_symbol); + /* Determine the common data type between two data types. * If no common data type found, return NULL. *