]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/52370 (Spurious "may be used uninitialized" warning for check of option...
authorJakub Jelinek <jakub@redhat.com>
Tue, 11 Feb 2014 20:48:26 +0000 (21:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 11 Feb 2014 20:48:26 +0000 (21:48 +0100)
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

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr52370.f90 [new file with mode: 0644]

index 89b34abff0f53fd4e13ab3e5aed33ab830213b43..c625a70e9e92bacdef381f57cd2f4965f8028cae 100644 (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
index bb02f43381fbeb1762457d4f411ee93395eec3a3..9c86653e22ea9fe968b49a8b04fab1812b62d32a 100644 (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);
index 6d3743afddb79116d99145aecedb2d06f498833f..b9a4cd15b0b4853615197039da08c9b8a43ca6ed 100644 (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
diff --git a/gcc/testsuite/gfortran.dg/pr52370.f90 b/gcc/testsuite/gfortran.dg/pr52370.f90
new file mode 100644 (file)
index 0000000..66a6fe2
--- /dev/null
@@ -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