I found this argument mismatch when looking into the issue of PR92305.

For noncharacter per-VALUE optional arguments, the absent/present status is propagated using a hidden argument of type 'boolean_type_node' (which is a one-byte type). If the (actual) argument in the caller is also an optional variable, gfc_conv_expr_present()  is called to obtain the pass-on condition.

For another per-VALUE argument, that's fine. However, for other optional arguments, the condition "arg == NULL" is folded to a logical_type_node (= default-kind logical, i.e. usually 4 sometimes 8 byte variable).

Hence, I added a fold-convert to ensure the right type is used.

Committed to the trunk as obvious, Rev. 278114.

Cheers,

Tobias

Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c	(revision 278113)
+++ gcc/fortran/trans-expr.c	(revision 278114)
@@ -5750,7 +5750,9 @@
 					fold_convert (TREE_TYPE (parmse.expr),
 						      integer_zero_node));
 
-			    vec_safe_push (optionalargs, tmp);
+			    vec_safe_push (optionalargs,
+					   fold_convert (boolean_type_node,
+							 tmp));
 			  }
 		      }
 		    }
Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(revision 278113)
+++ gcc/fortran/ChangeLog	(revision 278114)
@@ -1,3 +1,8 @@
+2019-11-13  Tobias Burnus  <tob...@codesourcery.com>
+
+	* trans-expr.c (gfc_conv_procedure_call): Fold hidden
+	is-present argument to the right type.
+
 2019-11-12  Harald Anlauf  <anl...@gmx.de>
 
 	PR fortran/81651
@@ -55,9 +60,9 @@
 
 2019-11-11  Janne Blomqvist  <j...@gcc.gnu.org>
 
-        PR fortran/91828
-        * simplify.c (gfc_simplify_fraction): Remove fallback path for
-        MPFR < 3.1.0.
+	PR fortran/91828
+	* simplify.c (gfc_simplify_fraction): Remove fallback path for
+	MPFR < 3.1.0.
 
 2019-11-11  Tobias Burnus  <tob...@codesourcery.com>
 	    Kwok Cheung Yeung  <k...@codesourcery.com>

Reply via email to