Skip to content
Snippets Groups Projects
Commit c8280e19 authored by FlorianKrull's avatar FlorianKrull
Browse files

Fixed unitialised error

parent 82ffce56
No related branches found
No related tags found
No related merge requests found
......@@ -400,11 +400,9 @@ void mcc_print_cfg_dot(struct mcc_tac *tac, FILE *out)
case MCC_TAC_FUNCTION_END:
snprintf(label, sizeof(label),"return (%s)\n", op_type);
print_dot_node(out,entry,label);
if(next_entry->tac_op == MCC_TAC_LABEL){
print_dot_edge_label(out,entry,next_entry->result,false);
}else{
check_dot_edge(out,entry,next_entry,"");
}
// if(next_entry->tac_op == MCC_TAC_LABEL){
// print_dot_edge_label(out,entry,next_entry->result,false);
// }
print_dot_end(out);
break;
case MCC_TAC_FUNCTION_START:
......
......@@ -43,6 +43,7 @@ struct mcc_tac *mcc_tac_new(struct mcc_tac *prev_tac, struct mcc_symbol_table *s
tac->prev = prev_tac;
tac->next = NULL;
tac->label_count = 0;
if(prev_tac != NULL) {
prev_tac->next = tac;
......
......@@ -38,7 +38,7 @@ void mcc_tac_parse_expression(struct mcc_ast_expression *expression, struct mcc_
case MCC_AST_EXPRESSION_TYPE_LITERAL : {
struct mcc_ast_literal *literal = expression->literal;
enum mcc_tac_operation op = mcc_convert_ast_type_to_tac_literal(literal->type);
char *arg1 = malloc((size_t) mcc_get_number_of_digits(tac->temporary_count) + 2);
char *arg1 = malloc((size_t) mcc_get_number_of_digits(tac->temporary_count) + 10);
switch(op) {
case MCC_TAC_BOOL :
arg1 = literal->b_value ? "true" : "false";
......@@ -121,7 +121,7 @@ void mcc_tac_parse_expression(struct mcc_ast_expression *expression, struct mcc_
if (is_array) {
int number_of_digits = mcc_get_number_of_digits(array_size);
char *arg1 = malloc(sizeof(char) * number_of_digits + 1);
char *arg1 = malloc(sizeof(char) * number_of_digits + 10);
sprintf(arg1, "%ld", array_size);
}
......
......@@ -24,6 +24,7 @@ char *mcc_tac_new_temporary_string(struct mcc_tac *tac) {
char *mcc_tac_new_label_string(struct mcc_tac *tac) {
// + 2 for character L and for \0 and + 1 in case temporay_count is 0
size_t num_digits = (size_t) mcc_get_number_of_digits(tac -> label_count) + 1 + 2;
char *l = malloc(num_digits);
......
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