User account creation filtered due to spam.

Bug 20811 - gfortran include problem (regression from g77)
Summary: gfortran include problem (regression from g77)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.3
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/fortran/2005-11...
Keywords: patch, rejects-valid
: 23460 (view as bug list)
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-04-07 14:30 UTC by afranck
Modified: 2005-11-18 12:42 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-15 12:31:50


Attachments
Source in gcc/fortran from FC4 4.0.1 with patches (7.36 KB, application/octet-stream)
2005-11-04 17:22 UTC, Mark Smith
Details
Source in gcc/libgfortran from FC4 gcc 4.0.1 with patches (14.87 KB, application/octet-stream)
2005-11-04 17:24 UTC, Mark Smith
Details

Note You need to log in before you can comment on or make changes to this bug.
Description afranck 2005-04-07 14:30:28 UTC
Hello,

doing some experiments with gfortran, I stumbled across the following
bug/regression with respect to g77:

consider these two files in a directory "test":

$ cat test/foo.f:
      subroutine foo
      include   'test.h'
      end

$ cat test/test.h
c  just a comment

Now, compiling with g77:

~ $ g77 -c test/foo.f
[works ok]

and with gfortran:

~ $ gfortran -c test/foo.f
Error: Can't open included file 'test.h'

If I compile within "test":

~/test $ gfortran -c foo.f
[works ok]

everything is fine.

But "include" is IMHO supposed to include from where the source file is located,
not only in the current directory?

Greetings,
Andreas
Comment 1 Andrew Pinski 2005-04-07 16:45:11 UTC
Confirmed.
Comment 2 Brian Swift 2005-08-16 16:37:15 UTC
FYI, ifort_8.0.046, Absoft Fortran 95 9.0 EP, pgf95 6.0-2, SGI f90 7.4, and g95
will all find and use the included file in the same directory as the source
without requiring extra '-I' command line options.
Comment 3 Tobias Schlüter 2005-11-01 21:24:26 UTC
*** Bug 23460 has been marked as a duplicate of this bug. ***
Comment 4 Mark Smith 2005-11-04 17:22:18 UTC
Created attachment 10145 [details]
Source in gcc/fortran from FC4 4.0.1 with patches
Comment 5 Mark Smith 2005-11-04 17:24:26 UTC
Created attachment 10146 [details]
Source in gcc/libgfortran from FC4 gcc 4.0.1 with patches
Comment 6 Mark Smith 2005-11-04 17:30:17 UTC
The two attached files will change the behavior so that included files are processed as described in comment #2. I have not checked the results extensively.
Comment 7 Francois-Xavier Coudert 2005-11-15 12:31:50 UTC
(In reply to comment #6)
> The two attached files will change the behavior so that included files are
> processed as described in comment #2. I have not checked the results
> extensively.

You should really attach patches and not the files themselves. Now, I don't know exactly what you changed in those files. And I'm really wondering what you could possible change in Makefile.in :)

I'm assigning this bug to myself, as I intend to look into it in the next few days.
Comment 8 Francois-Xavier Coudert 2005-11-16 09:09:52 UTC
Patch submitted for review.
Comment 9 Francois-Xavier Coudert 2005-11-17 12:51:45 UTC
Subject: Bug 20811

Author: fxcoudert
Date: Thu Nov 17 12:51:41 2005
New Revision: 107120

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107120
Log:
	PR fortran/20811
	* scanner.c (gfc_open_included_file): Add an extra include_cwd
	argument. Only include files in the current working directory if
	its value is true.
	* gfortran.h: Change prototype for gfc_open_included_file.
	(load_file): Don't search for include files in the current working
	directory.
	* options.c (gfc_post_options): Add the directory of the source file
	to the list of paths for included files.
	* module.c (gfc_use_module): Look for module files in the current
	directory.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/scanner.c

Comment 10 Andreas Tobler 2005-11-17 20:51:08 UTC
After this patch libgfortran fails to build on darwin-ppc.

it does not find the selected_int_kind.inc in the libgfortran objdir when building libgfortran. (selected_int_kind.f90 compilation)

Reverting the patch brings me to a successful libgfortran build.
Comment 11 Andreas Tobler 2005-11-17 21:30:28 UTC
Adding -I. to FC in the Makefile of libgfortran makes my compile happy again.
Comment 12 Francois-Xavier Coudert 2005-11-18 12:40:50 UTC
Subject: Bug 20811

Author: fxcoudert
Date: Fri Nov 18 12:40:42 2005
New Revision: 107177

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107177
Log:
	PR fortran/20811
	PR fortran/24892

	* io/io.h (unit_access): Add ACCESS_APPEND.
	* io/open.c (access_opt): Add APPEND value for ACCESS keyword.
	(st_open): Use that new value to set the POSITION accordingly.
	* configure.ac: Add "-I ." to AM_FCFLAGS.
	* configure: Regenerate.

	* scanner.c (gfc_open_included_file): Add an extra include_cwd
	argument. Only include files in the current working directory if
	its value is true.
	* gfortran.h: Change prototype for gfc_open_included_file.
	(load_file): Don't search for include files in the current working
	directory.
	* options.c (gfc_post_options): Add the directory of the source file
	to the list of paths for included files.
	* module.c (gfc_use_module): Look for module files in the current
	directory.

Modified:
    branches/gcc-4_0-branch/gcc/fortran/ChangeLog
    branches/gcc-4_0-branch/gcc/fortran/gfortran.h
    branches/gcc-4_0-branch/gcc/fortran/module.c
    branches/gcc-4_0-branch/gcc/fortran/options.c
    branches/gcc-4_0-branch/gcc/fortran/scanner.c
    branches/gcc-4_0-branch/libgfortran/ChangeLog
    branches/gcc-4_0-branch/libgfortran/configure
    branches/gcc-4_0-branch/libgfortran/configure.ac
    branches/gcc-4_0-branch/libgfortran/io/io.h
    branches/gcc-4_0-branch/libgfortran/io/open.c

Comment 13 Francois-Xavier Coudert 2005-11-18 12:42:43 UTC
This is now fixed on both 4.0 and mainline. Problems underlined in comment #10 fixed too.