aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-12-16 20:41:13 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-12-16 20:41:13 +0100
commitc2d42d16195d87ad6fb063a0db0287ad197a972b (patch)
tree30ead16302dba1ee72ae8b041d1a060178ebf480 /gcc/fortran/trans-expr.c
parentd380fed1e0862ddb32ee911335af9053d0e70894 (diff)
downloadgcc-c2d42d16195d87ad6fb063a0db0287ad197a972b.zip
gcc-c2d42d16195d87ad6fb063a0db0287ad197a972b.tar.gz
gcc-c2d42d16195d87ad6fb063a0db0287ad197a972b.tar.bz2
re PR fortran/78757 (ICE with function returning a pointer to a character)
PR fortran/78757 * trans-expr.c (gfc_conv_procedure_call): Emit DECL_EXPR for the type pstr var points to. * gfortran.dg/char_result_16.f90: New test. From-SVN: r243761
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index f908c25..823c96a 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6009,6 +6009,19 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
{
var = gfc_create_var (type, "pstr");
+ /* Emit a DECL_EXPR for the VLA type. */
+ tmp = TREE_TYPE (type);
+ if (TYPE_SIZE (tmp)
+ && TREE_CODE (TYPE_SIZE (tmp)) != INTEGER_CST)
+ {
+ tmp = build_decl (input_location, TYPE_DECL, NULL_TREE, tmp);
+ DECL_ARTIFICIAL (tmp) = 1;
+ DECL_IGNORED_P (tmp) = 1;
+ tmp = fold_build1_loc (input_location, DECL_EXPR,
+ TREE_TYPE (tmp), tmp);
+ gfc_add_expr_to_block (&se->pre, tmp);
+ }
+
if ((!comp && sym->attr.allocatable)
|| (comp && comp->attr.allocatable))
{