diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-08-06 21:32:09 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-08-06 21:32:09 +0000 |
commit | e0af8f52b10385d859d60a4ee6b89d274e4044bb (patch) | |
tree | 738a20ebf9f668b479b13bf5bb6d736c7435316c /gcc/fortran/trans-decl.c | |
parent | 1a3920654f92b83a206d62f4eddcf1f5c28a91de (diff) | |
download | gcc-e0af8f52b10385d859d60a4ee6b89d274e4044bb.zip gcc-e0af8f52b10385d859d60a4ee6b89d274e4044bb.tar.gz gcc-e0af8f52b10385d859d60a4ee6b89d274e4044bb.tar.bz2 |
re PR fortran/91359 (logical function X returns .TRUE. - Warning: spaghetti code)
2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91359
* trans-decl.c (gfc_generate_return): Ensure something is returned
from a function.
2019-08-06 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/91359
* gfortran.dg/pr91359_1.f: New test.
* gfortran.dg/pr91359_2.f: Ditto.
From-SVN: r274149
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r-- | gcc/fortran/trans-decl.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 96f0e1e..86c3d3a 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -6449,6 +6449,20 @@ gfc_generate_return (void) TREE_TYPE (result), DECL_RESULT (fndecl), result); } + else + { + /* If the function does not have a result variable, result is + NULL_TREE, and a 'return' is generated without a variable. + The following generates a 'return __result_XXX' where XXX is + the function name. */ + if (sym == sym->result && sym->attr.function) + { + result = gfc_get_fake_result_decl (sym, 0); + result = fold_build2_loc (input_location, MODIFY_EXPR, + TREE_TYPE (result), + DECL_RESULT (fndecl), result); + } + } } return build1_v (RETURN_EXPR, result); |