OSDN Git Service

2008-09-10 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2008 11:54:08 +0000 (11:54 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Sep 2008 11:54:08 +0000 (11:54 +0000)
        PR fortran/37420
        * trans-decl.c (get_proc_pointer_decl): Fix -Wunused-variable.

2008-09-10  Tobias Burnus  <burnus@net-b.de>

        PR fortran/37420
        * gfortran.dg/warn_unused_var.f90: New test.
        * gfortran.dg/warn_unused_var.f90: Add cleanup-modules.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140229 138bc75d-0d04-0410-961f-82ee72b054a4

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

index c8f1aaf..eef75e2 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-10  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/37420
+       * trans-decl.c (get_proc_pointer_decl): Fix -Wunused-variable.
+
 2008-09-09  Daniel Kraft  <d@domob.eu>
 
        PR fortran/37429
index 72f5973..ec00ee2 100644 (file)
@@ -1170,7 +1170,8 @@ get_proc_pointer_decl (gfc_symbol *sym)
   decl = build_decl (VAR_DECL, get_identifier (sym->name),
                     build_pointer_type (gfc_get_function_type (sym)));
 
-  if (sym->ns->proc_name->backend_decl == current_function_decl
+  if ((sym->ns->proc_name
+      && sym->ns->proc_name->backend_decl == current_function_decl)
       || sym->attr.contained)
     gfc_add_decl_to_function (decl);
   else
@@ -3476,11 +3477,6 @@ generate_local_decl (gfc_symbol * sym)
 {
   if (sym->attr.flavor == FL_VARIABLE)
     {
-      /* Check for dependencies in the array specification and string
-       length, adding the necessary declarations to the function.  We
-       mark the symbol now, as well as in traverse_ns, to prevent
-       getting stuck in a circular dependency.  */
-      sym->mark = 1;
       if (!sym->attr.dummy && !sym->ns->proc_name->attr.entry_master)
         generate_dependency_declarations (sym);
 
@@ -3516,6 +3512,12 @@ generate_local_decl (gfc_symbol * sym)
          gfc_get_symbol_decl (sym);
        }
 
+      /* Check for dependencies in the array specification and string
+       length, adding the necessary declarations to the function.  We
+       mark the symbol now, as well as in traverse_ns, to prevent
+       getting stuck in a circular dependency.  */
+      sym->mark = 1;
+
       /* We do not want the middle-end to warn about unused parameters
          as this was already done above.  */
       if (sym->attr.dummy && sym->backend_decl != NULL_TREE)
@@ -3545,7 +3547,7 @@ generate_local_decl (gfc_symbol * sym)
                        &sym->result->declared_at);
 
          /* Prevents "Unused variable" warning for RESULT variables.  */
-         sym->mark = sym->result->mark = 1;
+         sym->result->mark = 1;
        }
     }
 
index 51332f3..f78e376 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-10  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/37420
+       * gfortran.dg/warn_unused_var.f90: New test.
+       * gfortran.dg/warn_unused_var.f90: Add cleanup-modules.
+
 2008-09-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/37353
index 8136a18..4e9c256 100644 (file)
@@ -21,3 +21,5 @@ program startest
    if('#'//Q2//'#' /='#abcdefghijkl#') call abort()
    call sub('ABCDEFGHIJKLM') ! len=13
 end program startest
+
+! { dg-final { cleanup-modules "mod" } }
diff --git a/gcc/testsuite/gfortran.dg/warn_unused_var.f90 b/gcc/testsuite/gfortran.dg/warn_unused_var.f90
new file mode 100644 (file)
index 0000000..1858e68
--- /dev/null
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! { dg-options "-Wunused-variable" }
+!
+! PR fortran/37420
+!
+integer :: i ! { dg-warning "Unused variable" }
+end