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
This commit is contained in:
Jakub Jelinek 2014-02-11 21:48:26 +01:00 committed by Jakub Jelinek
parent fe89bba406
commit 879287d96b
4 changed files with 36 additions and 0 deletions

View File

@ -1,3 +1,9 @@
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>
PR fortran/57522

View File

@ -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);

View File

@ -1,3 +1,8 @@
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>
PR target/59927

View File

@ -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