diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 89b34abff0f..c625a70e9e9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2014-02-11 Jakub Jelinek + + PR fortran/52370 + * trans-decl.c (gfc_build_dummy_array_decl): Set TREE_NO_WARNING + on decl if sym->attr.optional. + 2014-02-09 Paul Thomas PR fortran/57522 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index bb02f43381f..9c86653e22e 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1014,6 +1014,10 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy) TREE_STATIC (decl) = 0; DECL_EXTERNAL (decl) = 0; + /* Avoid uninitialized warnings for optional dummy arguments. */ + if (sym->attr.optional) + TREE_NO_WARNING (decl) = 1; + /* We should never get deferred shape arrays here. We used to because of frontend bugs. */ gcc_assert (sym->as->type != AS_DEFERRED); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6d3743afddb..b9a4cd15b0b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-11 Jakub Jelinek + + PR fortran/52370 + * gfortran.dg/pr52370.f90: New test. + 2014-02-11 Uros Bizjak PR target/59927 diff --git a/gcc/testsuite/gfortran.dg/pr52370.f90 b/gcc/testsuite/gfortran.dg/pr52370.f90 new file mode 100644 index 00000000000..66a6fe2b80d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr52370.f90 @@ -0,0 +1,21 @@ +! PR fortran/52370 +! { dg-do compile } +! { dg-options "-O1 -Wall" } + +module pr52370 +contains + subroutine foo(a,b) + real, intent(out) :: a + real, dimension(:), optional, intent(out) :: b + a=0.5 + if (present(b)) then + b=1.0 + end if + end subroutine foo +end module pr52370 + +program prg52370 + use pr52370 + real :: a + call foo(a) +end program prg52370