Bug 28817 - [gfortran] problems with -Wunused
Summary: [gfortran] problems with -Wunused
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: diagnostic
Depends on: 21918
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-23 08:28 UTC by Martin Reinecke
Modified: 2006-09-18 06:55 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail: 4.2.0
Last reconfirmed: 2006-09-16 19:58:03


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Reinecke 2006-08-23 08:28:32 UTC
The following code causes current mainline gfortran to produce warnings
about unused variables that are somewhat confused.

module test
contains

subroutine sub1 (arg1)
  integer arg1
  integer var1
end subroutine

subroutine sub2 (arg2)
  integer arg2
  integer var2
  call something(arg2)
end subroutine

end module test

martin@linux:~/tmp> gfortran -c -Wunused test.f90
test.f90: In function ‘sub2’:
test.f90:4: warning: unused variable ‘var2’
test.f90: In function ‘sub1’:
test.f90:12: warning: unused variable ‘arg1’
test.f90:12: warning: unused variable ‘var1’

The diagnostics appear in the wrong order, and the line numbers are confused.
This is most likely related to (or identical with) PR21918.
Comment 1 Paul Thomas 2006-09-14 09:09:24 UTC
> This is most likely related to (or identical with) PR21918.

Martin, that is spot on.  In fact, Tobi's patch works fine; albeit a bit more verbosely.  Also, the locii need to be indirectly referenced, otherwise a segfault occurs.

Paul

Comment 2 Paul Thomas 2006-09-16 19:58:03 UTC
I propose to submit Tobi's patch

Paul
Comment 3 patchapp@dberlin.org 2006-09-17 12:45:27 UTC
Subject: Bug number PR28817

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-09/msg00674.html
Comment 4 Paul Thomas 2006-09-18 06:25:06 UTC
Subject: Bug 28817

Author: pault
Date: Mon Sep 18 06:24:54 2006
New Revision: 117014

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117014
Log:
2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* iresolve.c (resolve_spread): Build shape for result if the
	source shape is available and dim and ncopies are constants.

	PR fortran/28817
	PR fortran/21918
	* trans-decl.c (generate_local_decl): Change from 'warning' to
	'gfc_warning' to have line numbers correctly reported.

2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* gfortran.dg/spread_shape_1.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/spread_shape_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2006-09-18 06:46:51 UTC
Subject: Bug 28817

Author: pault
Date: Mon Sep 18 06:46:36 2006
New Revision: 117015

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117015
Log:
2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* iresolve.c (resolve_spread): Build shape for result if the
	source shape is available and dim and ncopies are constants.

	PR fortran/28817
	PR fortran/21918
	* trans-decl.c (generate_local_decl): Change from 'warning' to
	'gfc_warning' to have line numbers correctly reported.

2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* gfortran.dg/spread_shape_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/spread_shape_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/iresolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2006-09-18 06:55:27 UTC
Fixed on trunk and 4.1

Paul
Comment 7 Paul Thomas 2006-09-18 22:02:37 UTC
Subject: Bug 28817

Author: pault
Date: Mon Sep 18 22:02:24 2006
New Revision: 117038

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117038
Log:
2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* iresolve.c (resolve_spread): Build shape for result if the
	source shape is available and dim and ncopies are constants.

	PR fortran/28817
	PR fortran/21918
	* trans-decl.c (generate_local_decl): Change from 'warning' to
	'gfc_warning' to have line numbers correctly reported.

2006-09-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/29060
	* gfortran.dg/spread_shape_1.f90: New test.

Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/spread_shape_1.f90