Skip to content
Snippets Groups Projects
Commit bc1516ce authored by Clemens Paumgarten's avatar Clemens Paumgarten
Browse files

Fix segfault on array binar op check

parent 5940e8df
No related branches found
No related tags found
No related merge requests found
...@@ -160,7 +160,7 @@ int mcc_symbol_table_parse_statement( ...@@ -160,7 +160,7 @@ int mcc_symbol_table_parse_statement(
} else { } else {
return 1; return 1;
} }
case MCC_AST_STATEMENT_TYPE_IF:; case MCC_AST_STATEMENT_TYPE_IF:
if(mcc_symbol_table_validate_expression( if(mcc_symbol_table_validate_expression(
statement->if_condition, symbol_table, ec) == 0) { statement->if_condition, symbol_table, ec) == 0) {
if (mcc_symbol_table_validate_condition_to_type_bool( if (mcc_symbol_table_validate_condition_to_type_bool(
......
...@@ -340,7 +340,7 @@ int binary_operator_contains_illegal_array( ...@@ -340,7 +340,7 @@ int binary_operator_contains_illegal_array(
struct mcc_symbol_table *symbol_table, struct mcc_symbol_table *symbol_table,
struct mcc_symbol_table_error_collector *ec struct mcc_symbol_table_error_collector *ec
) { ) {
if (expression -> identifier != NULL) { if (expression -> type == MCC_AST_EXPRESSION_TYPE_IDENTIFIER && expression -> identifier != NULL) {
struct mcc_symbol *s = mcc_symbol_table_get_symbol(symbol_table, expression->identifier->i_value); struct mcc_symbol *s = mcc_symbol_table_get_symbol(symbol_table, expression->identifier->i_value);
// this is a binary op with an array without index provided // this is a binary op with an array without index provided
...@@ -371,8 +371,7 @@ int mcc_symbol_table_validate_binary_operator( ...@@ -371,8 +371,7 @@ int mcc_symbol_table_validate_binary_operator(
} }
int illegal_array_op_lhs = binary_operator_contains_illegal_array(expression->lhs, symbol_table, ec); int illegal_array_op_lhs = binary_operator_contains_illegal_array(expression->lhs, symbol_table, ec);
int illegal_array_op_rhs = binary_operator_contains_illegal_array(expression->lhs, symbol_table, ec); int illegal_array_op_rhs = binary_operator_contains_illegal_array(expression->rhs, symbol_table, ec);
if(illegal_array_op_lhs || illegal_array_op_rhs) { if(illegal_array_op_lhs || illegal_array_op_rhs) {
return 1; return 1;
} }
...@@ -437,7 +436,6 @@ int mcc_symbol_table_validate_expression( ...@@ -437,7 +436,6 @@ int mcc_symbol_table_validate_expression(
assert(symbol_table); assert(symbol_table);
assert(ec); assert(ec);
switch(expression->type) { switch(expression->type) {
case MCC_AST_EXPRESSION_TYPE_IDENTIFIER: case MCC_AST_EXPRESSION_TYPE_IDENTIFIER:
return mcc_symbol_table_validate_identifier(expression->identifier, symbol_table, ec); return mcc_symbol_table_validate_identifier(expression->identifier, symbol_table, ec);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment