Skip to content

Commit 38efdc5

Browse files
committed
Minor bug fixes and silencing false positive warnings
1 parent 62fb7b2 commit 38efdc5

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

src/AST/ast_layout.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ successful_t ast_layout_endpoint_init_with(ast_layout_endpoint_t *endpoint, uint
408408
// Set end index, so we can determine the length of this endpoint's indices
409409
if(length != AST_LAYOUT_MAX_DEPTH) endpoint->indices[length] = AST_LAYOUT_ENDPOINT_END_INDEX;
410410

411+
// Silence warnings about copying uninitialized data
412+
memset(endpoint->indices, 0, sizeof(uint16_t) * AST_LAYOUT_MAX_DEPTH);
413+
411414
memcpy(endpoint->indices, indices, sizeof(uint16_t) * length);
412415
return true;
413416
}

src/IR/ir_lowering.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,16 +412,16 @@ errorcode_t ir_lower_const_xitofp(ir_pool_t *pool, ir_value_t **inout_value){
412412

413413
switch(from_spec.bytes){
414414
case 1:
415-
as_float = is_signed ? *((int8_t*) ((*child)->extra)) : *((uint8_t*) ((*child)->extra));
415+
as_float = is_signed ? (double) *((int8_t*) ((*child)->extra)) : (double) *((uint8_t*) ((*child)->extra));
416416
break;
417417
case 2:
418-
as_float = is_signed ? *((int16_t*) ((*child)->extra)) : *((uint16_t*) ((*child)->extra));
418+
as_float = is_signed ? (double) *((int16_t*) ((*child)->extra)) : (double) *((uint16_t*) ((*child)->extra));
419419
break;
420420
case 4:
421-
as_float = is_signed ? *((int32_t*) ((*child)->extra)) : *((uint32_t*) ((*child)->extra));
421+
as_float = is_signed ? (double) *((int32_t*) ((*child)->extra)) : (double) *((uint32_t*) ((*child)->extra));
422422
break;
423423
case 8:
424-
as_float = is_signed ? *((int64_t*) ((*child)->extra)) : *((uint64_t*) ((*child)->extra));
424+
as_float = is_signed ? (double) *((int64_t*) ((*child)->extra)) : (double) *((uint64_t*) ((*child)->extra));
425425
break;
426426
default:
427427
internalerrorprintf("ir_lower_const_xitofp() - Could not perform operation\n");

src/IRGEN/ir_builder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ errorcode_t attempt_autogen___assign__(compiler_t *compiler, object_t *object, a
14111411

14121412
entry->has_assign = TROOLEAN_FALSE;
14131413

1414-
ast_field_map_t field_map;
1414+
ast_field_map_t field_map = {/*zeroed*/};
14151415

14161416
// Cannot make if type is not a composite or if it's not simple
14171417
if(subject_is_base_ptr){

src/PARSE/parse_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ errorcode_t parse_switch(parse_ctx_t *ctx, ast_expr_list_t *stmt_list, defer_sco
953953
ast_case_t *newest_case = ast_case_list_append(&cases, (ast_case_t){
954954
.condition = condition,
955955
.source = case_source,
956-
.statements = {0},
956+
.statements = {/*zeroed*/},
957957
});
958958

959959
list = &newest_case->statements;

0 commit comments

Comments
 (0)