Consider the following piece of code: module A type A_type real comp end type end module A module B use A private type(A_type) :: B_var public:: B_var end module B program C use B use A type(A_type):: A_var end program C This is rejected with the error message type(A_type):: A_var 1 Error: Derived type 'a_type' at (1) is being used before it is defined Please note that the error is only thrown under the condition that the USE statements in program C appear in the same order as shown above. When you exchange them and put "use A" first (or remove "use B"), then the error goes away. This makes me wonder if this bug is somehow related to PR33295. Also the error only appears with the funny combination of PUBLIC and PRIVATE in module B. Admittedly, it looks a little strange and is not very useful, but nevertheless I think it's valid Fortran (someone correct me if I'm wrong).
The code above fails for recent trunk builds (rev. 130582) on i686-pc-linux-gnu, but is known to work for 4.2.1 as well as 4.3.0 rev. 127773 (from August 24, 2007).
The error also appears on x86_64. It must have been introduced somewhere between Nov. 23 and 26: - rev. 130365 works - rev. 130431 fails
Paul, do you have an idea? My (un)educated guess is that the fix for PR 33541 (patch to not import "y" when using "use foo; use foo, only: x => y") caused this.
(In reply to comment #3) > Paul, do you have an idea? My (un)educated guess is that the fix for PR 33541 > (patch to not import "y" when using "use foo; use foo, only: x => y") caused > this. I don't think your guess is uneducated at all. I nailed the error down to revision 130395, which is Paul's fix for PR33541.
*** Bug 34339 has been marked as a duplicate of this bug. ***
(In reply to comment #5) > *** Bug 34339 has been marked as a duplicate of this bug. *** > OK Thanks all - I'm onto it. Paul
Subject: Bug 34335 Author: pault Date: Thu Dec 6 06:13:59 2007 New Revision: 130643 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130643 Log: 2007-12-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/34335 * module.c (find_symbol): Do not return symtrees with unique names, which shows that they are private. 2007-12-06 Paul Thomas <pault@gcc.gnu.org> PR fortran/34335 * gfortran.dg/used_types_19.f90: New test. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/testsuite/ChangeLog
Fixed on trunk Paul
The actual commit is: http://gcc.gnu.org/viewcvs?view=rev&revision=130642 Thanks for the fix!