Bug 36374 - nested module inclusion fails
Summary: nested module inclusion fails
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2008-05-29 16:00 UTC by Salvatore Filippone
Modified: 2008-09-23 06:29 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail: 4.1.3 4.2.2 4.3.0 4.4.0
Last reconfirmed: 2008-09-01 10:28:38


Attachments
test case (310 bytes, text/plain)
2008-05-29 16:01 UTC, Salvatore Filippone
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Salvatore Filippone 2008-05-29 16:00:00 UTC
The attached code produces an error message, yet it is accepted by other compilers and is judged legal in 
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/82aebb2460cba148#



[sfilippo@localhost bugtest]$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.0/configure --prefix=/usr/local/gcc43 --with-mpfr=/u
sr/local/mpfr --with-gmp=/usr/local/gmp
Thread model: posix
gcc version 4.3.0 (GCC) 
[sfilippo@localhost bugtest]$ gfortran -c usemod2.f90
usemod2.f90:39.34:

  use foo_mod, protect => s_foobar
                                 1
Error: Name 'foobar' at (1) is an ambiguous reference to 'foobar' from module 's
_foo_mod'
usemod2.f90:46.34:

  use foo_mod, protect => d_foobar
                                 1
Error: Name 'foobar' at (1) is an ambiguous reference to 'foobar' from module 's
_foo_mod'
usemod2.f90:54.13:

  use foo_mod
            1
Error: Name 'foobar' at (1) is an ambiguous reference to 'foobar' from module 's
_foo_mod'
usemod2.f90:57.16:

  call foobar(z)
               1
Error: There is no specific subroutine for the generic 'foobar' at (1)
Comment 1 Salvatore Filippone 2008-05-29 16:01:20 UTC
Created attachment 15701 [details]
test case

Fails on gcc version 4.4.0 20080509  as well
Comment 2 Tobias Burnus 2008-05-29 21:02:28 UTC
Paul, do you have an idea? You are our module/interface specialist.
Comment 3 Paul Thomas 2008-09-01 10:28:37 UTC
(In reply to comment #2)
> Paul, do you have an idea? You are our module/interface specialist.
> 

I have started to take a look at it.

Cheers

Paul
Comment 4 Paul Thomas 2008-09-17 22:25:16 UTC
Subject: Bug 36374

Author: pault
Date: Wed Sep 17 22:23:51 2008
New Revision: 140434

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

	PR fortran/37274
	PR fortran/36374
	* module.c (check_for_ambiguous): New function to test loaded
	symbol for ambiguity with fixup symbol.
	(read_module): Call check_for_ambiguous.
	(write_symtree): Do not write the symtree for symbols coming
	from an interface body.

	PR fortran/36374
	* resolve.c (count_specific_procs ): New function to count the
	number of specific procedures with the same name as the generic
	and emit appropriate errors for and actual argument reference.
	(resolve_assumed_size_actual): Add new argument no_formal_args.
	Correct logic around passing generic procedures as arguments.
	Call count_specific_procs from two locations.
	(resolve_function): Evaluate and pass no_formal_args.
	(resolve call): The same and clean up a bit by using csym more
	widely.

	PR fortran/36454
	* symbol.c (gfc_add_access): Access can be updated if use
	associated and not private.

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

	PR fortran/37274
	* gfortran.dg/used_types_22.f90: New test.
	* gfortran.dg/used_types_23.f90: New test.

	PR fortran/36374
	* gfortran.dg/generic_17.f90: New test.
	* gfortran.dg/ambiguous_specific_2.f90: New test.
	* gfortran.dg/generic_actual_arg.f90: Add test for case that is
	not ambiguous.

	PR fortran/36454
	* gfortran.dg/access_spec_3.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/access_spec_3.f90
    trunk/gcc/testsuite/gfortran.dg/ambiguous_specific_2.f90
    trunk/gcc/testsuite/gfortran.dg/generic_17.f90
    trunk/gcc/testsuite/gfortran.dg/used_types_22.f90
    trunk/gcc/testsuite/gfortran.dg/used_types_23.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/generic_actual_arg.f90

Comment 5 Paul Thomas 2008-09-17 22:31:54 UTC
Fixed on trunk.  I'll wait a few days for 4.3.0.

Thanks for the report.

Paul
Comment 6 Paul Thomas 2008-09-23 06:27:16 UTC
Subject: Bug 36374

Author: pault
Date: Tue Sep 23 06:25:39 2008
New Revision: 140578

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

	PR fortran/37274
	PR fortran/36374
	* module.c (check_for_ambiguous): New function to test loaded
	symbol for ambiguity with fixup symbol.
	(read_module): Call check_for_ambiguous.
	(write_symtree): Do not write the symtree for symbols coming
	from an interface body.

	PR fortran/36374
	* resolve.c (count_specific_procs ): New function to count the
	number of specific procedures with the same name as the generic
	and emit appropriate errors for and actual argument reference.
	(resolve_assumed_size_actual): Add new argument no_formal_args.
	Correct logic around passing generic procedures as arguments.
	Call count_specific_procs from two locations.
	(resolve_function): Evaluate and pass no_formal_args.
	(resolve call): The same and clean up a bit by using csym more
	widely.

	PR fortran/36454
	* symbol.c (gfc_add_access): Access can be updated if use
	associated and not private.

2008-09-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/37274
	* gfortran.dg/used_types_22.f90: New test.
	* gfortran.dg/used_types_23.f90: New test.

	PR fortran/36374
	* gfortran.dg/generic_17.f90: New test.
	* gfortran.dg/ambiguous_specific_2.f90: New test.
	* gfortran.dg/generic_actual_arg.f90: Add test for case that is
	not ambiguous.

	PR fortran/36454
	* gfortran.dg/access_spec_3.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/access_spec_3.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/ambiguous_specific_2.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/generic_17.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/used_types_22.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/used_types_23.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/module.c
    branches/gcc-4_3-branch/gcc/fortran/resolve.c
    branches/gcc-4_3-branch/gcc/fortran/symbol.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/generic_actual_arg.f90

Comment 7 Paul Thomas 2008-09-23 06:29:16 UTC
Fixed on trunk and 4.3.

Thanks for the report

Paul