[multiple changes]

2012-01-09  Mikael Morin  <mikael@gcc.gnu.org>

	PR fortran/51758
	* trans-array.c (gfc_walk_elemental_function_args):
	Skip over NULL() actual arguments.

2012-01-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/51758
	* gfortran.dg/optional_absent_2.f90: New.

From-SVN: r183024
This commit is contained in:
Mikael Morin 2012-01-09 19:01:34 +00:00
parent 3d137660a5
commit 80508c4992
4 changed files with 65 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2012-01-09 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/51758
* trans-array.c (gfc_walk_elemental_function_args):
Skip over NULL() actual arguments.
2012-01-09 Tobias Burnus <burnus@net-b.de>
* gfortran.texi: Bump copyright year.

View File

@ -8369,7 +8369,7 @@ gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
scalar = 1;
for (; arg; arg = arg->next)
{
if (!arg->expr)
if (!arg->expr || arg->expr->expr_type == EXPR_NULL)
continue;
newss = gfc_walk_subexpr (head, arg->expr);

View File

@ -1,3 +1,8 @@
2012-01-09 Tobias Burnus <burnus@net-b.de>
PR fortran/51758
* gfortran.dg/optional_absent_2.f90: New.
2012-01-09 Tobias Burnus <burnus@net-b.de>
PR fortran/51578

View File

@ -0,0 +1,53 @@
! { dg-do run }
!
! PR fortran/51758
!
! Contributed by Mikael Morin
!
! Check whether passing NULL() to an elemental procedure works,
! where NULL() denotes an absent optional argument.
!
program p
integer :: a(2)
integer :: b
a = 0
a = foo((/ 1, 1 /), null())
! print *, a
if (any(a /= 2)) call abort
a = 0
a = bar((/ 1, 1 /), null())
! print *, a
if (any(a /= 2)) call abort
b = 0
b = bar(1, null())
! print *, b
if (b /= 2) call abort
contains
function foo(a, b)
integer :: a(:)
integer, optional :: b(:)
integer :: foo(size(a))
if (present(b)) call abort
foo = 2
end function foo
elemental function bar(a, b)
integer, intent(in) :: a
integer, intent(in), optional :: b
integer :: bar
bar = 2
if (present(b)) bar = 1
end function bar
end program p