Commit 879287d9 by Jakub Jelinek Committed by Jakub Jelinek

re PR fortran/52370 (Spurious "may be used uninitialized" warning for check of optional argument)

	PR fortran/52370
	* trans-decl.c (gfc_build_dummy_array_decl): Set TREE_NO_WARNING
	on decl if sym->attr.optional.

	* gfortran.dg/pr52370.f90: New test.

From-SVN: r207698
parent fe89bba4
2014-02-11 Jakub Jelinek <jakub@redhat.com>
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 <pault@gcc.gnu.org> 2014-02-09 Paul Thomas <pault@gcc.gnu.org>
PR fortran/57522 PR fortran/57522
......
...@@ -1014,6 +1014,10 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy) ...@@ -1014,6 +1014,10 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
TREE_STATIC (decl) = 0; TREE_STATIC (decl) = 0;
DECL_EXTERNAL (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 /* We should never get deferred shape arrays here. We used to because of
frontend bugs. */ frontend bugs. */
gcc_assert (sym->as->type != AS_DEFERRED); gcc_assert (sym->as->type != AS_DEFERRED);
......
2014-02-11 Jakub Jelinek <jakub@redhat.com>
PR fortran/52370
* gfortran.dg/pr52370.f90: New test.
2014-02-11 Uros Bizjak <ubizjak@gmail.com> 2014-02-11 Uros Bizjak <ubizjak@gmail.com>
PR target/59927 PR target/59927
......
! 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment