This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR18428: use libcpp for preprocessing (review of C/C++ and fortran maintainers needed)


Hi all.

This is to integrate libcpp into gfortran and not to rely on cc1 to do the 
preprocessing. The change became necessary to simplify the implementation of 
feature requests and fixing of problems related to preprocessing.

Essentially, this patch does not change anything for the outside world but one 
detail: to preprocess files it is not necessary to rename x.f90 to x.F90, one 
now can also invoke:

	$> gfortran -cpp x.f90

Hence, any workarounds using "-x f95-cpp-input" or resorting to .spec-files is 
now obsolete.

The C changes may be devided into two parts: firstly, the cleanup of an 
undocumented option and its handling; secondly, moving some functionality 
from gcc to libbackend to be reused by the fortran frontend (see also [1]). 
The latter changes should be reviewed very carefully as I am not very 
involved in with the build process ...

On the fortran side, the largest part of the changes went into the new files 
cpp.[ch] - large portions of that code were borrowed from c-ppoutput. Any 
outside change should be simple and straight forward.

Still to do: general clean- and brushing up, testcases and documentation.

Besides the TODO items, I plan to implement/fix the following PRs next:
 * PR31588 - Makefile dependencies with -M* options
 * PR35707 - additional search paths for .mod files
 * PR35505 - missing path to finclude directory when compiling .F90 files

If the requirement of traditional-cpp can be dropped:
 * PR28662 - traditional-cpp versus newer macros like #x
 * PR29671 - preprocessor statements must start in column 1

Thanks to Tom Tromey and all others who helped me to implement this so far!


:ADDPATCH gcc/fortan:

gcc:
2008-04-23  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/18428
	* c.opt: Removed undocumented option '-lang-fortran'.
	* c-common.h: Removed global variable 'lang_fortran'.
	* c-opts.c (c_common_handle_option): Removed code to handle
	option '-lang-fortran'.
	* c-cppbuiltin.c (c_cpp_builtins): Removed conditional
	definition of '__GFORTRAN__'.
	(define__GNUC__): Reimplemented to use BASEVER and 
	cpp_define_formatted.
	(builtin_define_with_value_n): Removed.
	* c-incpath.h: Renamed to ...
	* incpath.h: ... this.
	* c-incpath.c: Renamed to ...
	* incpath.c: ... this.
	* fix-header.c: Updated includes.
	* Makefile.in: Replaced c-incpath.[ch] by incpath.[ch].
	(c-cppbuiltin.o): Added dependency on and definition of BASEVER.
	(OBJ-archive): Added cppdefault.o, incpath.o and prefix.o.
	(PROTO_OBJS): Adjusted dependencies.
	(fix-header): Likewise.


gcc/cp:
2008-04-23  Daniel Franke  <franke.daniel@gmail.com>

	* Makefile.in: Adjusted dependencies.


gcc/fortran:
2008-04-23  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/18428
	* lang.opt (A, C, CC, D, E, H, P, U, cpp, d, fworking-directory,
	imultilib, iprefix, iquote, isysroot, isystem, nostdinc, o, undef, v): 
	New options.
	* options.c (gfc_init_options): Also initialize preprocessor
	options.
	(gfc_post_options): Also handle post-initialization of preprocessor
	options.
	(gfc_handle_option): Check if option is a preprocessor option.
	If yes, let gfc_cpp_handle_option() handle the option.
	* lang-specs.h: Reorganized to handle new options.
	* scanner.c (gfc_new_file): Read temporary file instead of 
	input source if preprocessing is enabled.
	* f95-lang.c (gfc_init): Initialize preprocessor.
	(gfc_finish): Clean up preprocessor.
	* cpp.c: New.
	* cpp.h: New.
	* Make-lang.in: Added new objects and dependencies.


Bootstrapped and regression tested on i686-pc-linux-gnu.
Ok for trunk?

Regards

	Daniel

P.S. To apply the patch, one needs to manually rename c-incpath.[ch], 
otherwise it won't apply cleanly.

[1] http://gcc.gnu.org/ml/gcc/2008-04/msg00389.html

Attachment: pr18428.patch.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]