aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorTobias Schlüter <tobi@gcc.gnu.org>2006-12-21 04:04:43 +0100
committerTobias Schlüter <tobi@gcc.gnu.org>2006-12-21 04:04:43 +0100
commitda4c6ed815c2723b3e9f6ddc375ea915da62d207 (patch)
treee08435e41b0ca91e22171efc98b4f40e3898d64c /gcc/fortran/trans-decl.c
parent5165f1258bb2b110382156d62f46627e3e81654c (diff)
downloadgcc-da4c6ed815c2723b3e9f6ddc375ea915da62d207.zip
gcc-da4c6ed815c2723b3e9f6ddc375ea915da62d207.tar.gz
gcc-da4c6ed815c2723b3e9f6ddc375ea915da62d207.tar.bz2
re PR fortran/25392 (ICEs with -ff2c)
PR fortran/25392 fortran/ * trans-stmt.c (gfc_trans_return): Fix comment formatting. * trans-types.c (gfc_sym_type): Don't return early for functions. Remove special handling for -ff2c. (gfc_get_function_type): Add special handling for -ff2c. * trans-decl.c (gfc_create_function_decl): Fix comment formatting. (gfc_get_fake_result_decl): Make sure we get the right type for functions. (gfc_generate_function_code): Convert type of result variable to type of function. testsuite/ * gfortran.dg/f2c_8.f90: New test. From-SVN: r120099
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 815b15e..2a03416 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1777,7 +1777,7 @@ gfc_create_function_decl (gfc_namespace * ns)
}
/* Return the decl used to hold the function return value. If
- parent_flag is set, the context is the parent_scope*/
+ parent_flag is set, the context is the parent_scope. */
tree
gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
@@ -1886,9 +1886,12 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
sprintf (name, "__result_%.20s",
IDENTIFIER_POINTER (DECL_NAME (this_function_decl)));
- decl = build_decl (VAR_DECL, get_identifier (name),
- TREE_TYPE (TREE_TYPE (this_function_decl)));
-
+ if (!sym->attr.mixed_entry_master && sym->attr.function)
+ decl = build_decl (VAR_DECL, get_identifier (name),
+ gfc_sym_type (sym));
+ else
+ decl = build_decl (VAR_DECL, get_identifier (name),
+ TREE_TYPE (TREE_TYPE (this_function_decl)));
DECL_ARTIFICIAL (decl) = 1;
DECL_EXTERNAL (decl) = 0;
TREE_PUBLIC (decl) = 0;
@@ -3258,9 +3261,12 @@ gfc_generate_function_code (gfc_namespace * ns)
warning (0, "Function return value not set");
else
{
- /* Set the return value to the dummy result variable. */
- tmp = build2 (MODIFY_EXPR, TREE_TYPE (result),
- DECL_RESULT (fndecl), result);
+ /* Set the return value to the dummy result variable. The
+ types may be different for scalar default REAL functions
+ with -ff2c, therefore we have to convert. */
+ tmp = convert (TREE_TYPE (DECL_RESULT (fndecl)), result);
+ tmp = build2 (MODIFY_EXPR, TREE_TYPE (tmp),
+ DECL_RESULT (fndecl), tmp);
tmp = build1_v (RETURN_EXPR, tmp);
gfc_add_expr_to_block (&block, tmp);
}