Skip to content

Commit

Permalink
Fix: missing return statement error given for functions with auto r…
Browse files Browse the repository at this point in the history
…eturn type
  • Loading branch information
positively-charged committed Dec 6, 2016
1 parent 1747f30 commit b7b5983
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/semantic/stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ void s_test_func_block( struct semantic* semantic, struct func* func,
test.manual_scope = true;
test_block( semantic, &test, block );
check_dup_label( semantic );
// If the return type of the function is still `auto`, then the function has
// no return statements in its body, so the return type is `void`.
if ( func->return_spec == SPEC_AUTO ) {
func->return_spec = SPEC_VOID;
}
if ( semantic->lang == LANG_BCS ) {
if ( func->return_spec != SPEC_VOID && test.flow != FLOW_DEAD ) {
s_diag( semantic, DIAG_POS_ERR, &func->object.pos,
Expand Down

0 comments on commit b7b5983

Please sign in to comment.