aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2013-03-29 23:26:17 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2013-03-29 23:26:17 +0100
commit60f97ac8596d65a73164e2967e73404b99534f92 (patch)
tree5c179c350d8b5c238071125bf8bc0ecb063eff87 /gcc/fortran/trans-decl.c
parent50e10fa881de2b9fd82f83bc0c4c24227e2a4a97 (diff)
downloadgcc-60f97ac8596d65a73164e2967e73404b99534f92.zip
gcc-60f97ac8596d65a73164e2967e73404b99534f92.tar.gz
gcc-60f97ac8596d65a73164e2967e73404b99534f92.tar.bz2
re PR fortran/35203 (OPTIONAL, VALUE actual argument cannot be an INTEGER 0)
2013-03-29 Tobias Burnus <burnus@net-b.de> PR fortran/35203 * trans-decl.c (create_function_arglist): Pass hidden argument for passed-by-value optional+value dummies. * trans-expr.c (gfc_conv_expr_present, gfc_conv_procedure_call): Handle those. 2013-03-29 Tobias Burnus <burnus@net-b.de> PR fortran/35203 * gfortran.dg/optional_absent_3.f90: New. From-SVN: r197252
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 0e853ba..fafde89 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -2142,6 +2142,27 @@ create_function_arglist (gfc_symbol * sym)
type = gfc_sym_type (f->sym);
}
}
+ /* For noncharacter scalar intrinsic types, VALUE passes the value,
+ hence, the optional status cannot be transfered via a NULL pointer.
+ Thus, we will use a hidden argument in that case. */
+ else if (f->sym->attr.optional && f->sym->attr.value
+ && !f->sym->attr.dimension && !f->sym->ts.type != BT_CLASS
+ && f->sym->ts.type != BT_DERIVED)
+ {
+ tree tmp;
+ strcpy (&name[1], f->sym->name);
+ name[0] = '_';
+ tmp = build_decl (input_location,
+ PARM_DECL, get_identifier (name),
+ boolean_type_node);
+
+ hidden_arglist = chainon (hidden_arglist, tmp);
+ DECL_CONTEXT (tmp) = fndecl;
+ DECL_ARTIFICIAL (tmp) = 1;
+ DECL_ARG_TYPE (tmp) = boolean_type_node;
+ TREE_READONLY (tmp) = 1;
+ gfc_finish_decl (tmp);
+ }
/* For non-constant length array arguments, make sure they use
a different type node from TYPE_ARG_TYPES type. */