Commit 670637ee by Daniel Franke Committed by Daniel Franke

re PR fortran/18428 (No preprocessing option -cpp for gfortran)

gcc:
2008-05-26  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'. Updated includes.
	* 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. Updated includes.
	* 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.


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

	* Makefile.in: Adjusted dependencies on c-incpath.o.


gcc/fortran:
2008-05-26  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, nocpp, 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.
	* gfortran.texi: Updated section "Preprocessing and
	conditional compilation".
	* invoke.texi: Added new section "Preprocessing Options",
	listed and documented the preprocessing options handled by gfortran.

From-SVN: r135882
parent 4cea6c02
2008-05-26 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'. Updated includes.
* 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. Updated includes.
* 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.
2008-05-25 Eric Botcazou <ebotcazou@adacore.com> 2008-05-25 Eric Botcazou <ebotcazou@adacore.com>
* tree.h: Update the table of flags used on tree nodes. * tree.h: Update the table of flags used on tree nodes.
......
...@@ -976,7 +976,7 @@ GCC_OBJS = gcc.o opts-common.o gcc-options.o ...@@ -976,7 +976,7 @@ GCC_OBJS = gcc.o opts-common.o gcc-options.o
# Language-specific object files for C and Objective C. # Language-specific object files for C and Objective C.
C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \ C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \ c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \
c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ c-ppoutput.o c-cppbuiltin.o \
c-objc-common.o c-dump.o c-pch.o c-parser.o $(C_TARGET_OBJS) \ c-objc-common.o c-dump.o c-pch.o c-parser.o $(C_TARGET_OBJS) \
c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o
...@@ -1234,6 +1234,8 @@ OBJS-archive = \ ...@@ -1234,6 +1234,8 @@ OBJS-archive = \
cgraph.o \ cgraph.o \
cgraphbuild.o \ cgraphbuild.o \
cgraphunit.o \ cgraphunit.o \
cppdefault.o \
incpath.o \
ipa-cp.o \ ipa-cp.o \
ipa-inline.o \ ipa-inline.o \
ipa-prop.o \ ipa-prop.o \
...@@ -1244,6 +1246,7 @@ OBJS-archive = \ ...@@ -1244,6 +1246,7 @@ OBJS-archive = \
ipa-utils.o \ ipa-utils.o \
ipa.o \ ipa.o \
matrix-reorg.o \ matrix-reorg.o \
prefix.o \
tree-inline.o \ tree-inline.o \
tree-nomudflap.o \ tree-nomudflap.o \
varpool.o varpool.o
...@@ -1733,7 +1736,7 @@ srcextra: gcc.srcextra lang.srcextra ...@@ -1733,7 +1736,7 @@ srcextra: gcc.srcextra lang.srcextra
gcc.srcextra: gengtype-lex.c gcc.srcextra: gengtype-lex.c
-cp -p $^ $(srcdir) -cp -p $^ $(srcdir)
c-incpath.o: c-incpath.c c-incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \ incpath.o: incpath.c incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \ intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
$(MACHMODE_H) $(MACHMODE_H)
...@@ -1816,13 +1819,15 @@ c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \ ...@@ -1816,13 +1819,15 @@ c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \
c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h langhooks.h \ $(TREE_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h langhooks.h \
$(TREE_INLINE_H) $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) \ $(TREE_INLINE_H) $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) \
opts.h options.h $(MKDEPS_H) c-incpath.h cppdefault.h $(TM_P_H) opts.h options.h $(MKDEPS_H) incpath.h cppdefault.h $(TM_P_H)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) \ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@ $< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
c-cppbuiltin.o : c-cppbuiltin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ c-cppbuiltin.o : c-cppbuiltin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) version.h $(C_COMMON_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h \ $(TREE_H) version.h $(C_COMMON_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h \
output.h except.h $(REAL_H) $(TARGET_H) $(TM_P_H) output.h except.h $(REAL_H) $(TARGET_H) $(TM_P_H) $(BASEVER)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) -DBASEVER=$(BASEVER_s) \
$< $(OUTPUT_OPTION)
# A file used by all variants of C and some other languages. # A file used by all variants of C and some other languages.
...@@ -3590,10 +3595,10 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h \ ...@@ -3590,10 +3595,10 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h \
# This is nominally a 'build' program, but it's run only when host==build, # This is nominally a 'build' program, but it's run only when host==build,
# so we can (indeed, must) use $(LIBDEPS) and $(LIBS). # so we can (indeed, must) use $(LIBDEPS) and $(LIBS).
build/fix-header$(build_exeext): build/fix-header.o build/scan-decls.o \ build/fix-header$(build_exeext): build/fix-header.o build/scan-decls.o \
build/scan.o xsys-protos.h c-incpath.o cppdefault.o prefix.o \ build/scan.o xsys-protos.h \
$(BUILD_ERRORS) $(LIBDEPS) $(BUILD_ERRORS) $(LIBDEPS)
$(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \ $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ \
build/fix-header.o c-incpath.o cppdefault.o build/scan-decls.o prefix.o \ build/fix-header.o incpath.o cppdefault.o build/scan-decls.o prefix.o \
build/scan.o $(BUILD_ERRORS) $(LIBS) build/scan.o $(BUILD_ERRORS) $(LIBS)
build/fix-header.o: fix-header.c $(OBSTACK_H) scan.h errors.h \ build/fix-header.o: fix-header.c $(OBSTACK_H) scan.h errors.h \
......
...@@ -262,8 +262,6 @@ extern c_language_kind c_language; ...@@ -262,8 +262,6 @@ extern c_language_kind c_language;
#define c_dialect_cxx() (c_language & clk_cxx) #define c_dialect_cxx() (c_language & clk_cxx)
#define c_dialect_objc() (c_language & clk_objc) #define c_dialect_objc() (c_language & clk_objc)
extern bool lang_fortran;
/* Information about a statement tree. */ /* Information about a statement tree. */
struct stmt_tree_s GTY(()) { struct stmt_tree_s GTY(()) {
......
...@@ -48,8 +48,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -48,8 +48,6 @@ along with GCC; see the file COPYING3. If not see
/* Non-static as some targets don't use it. */ /* Non-static as some targets don't use it. */
void builtin_define_std (const char *) ATTRIBUTE_UNUSED; void builtin_define_std (const char *) ATTRIBUTE_UNUSED;
static void builtin_define_with_value_n (const char *, const char *,
size_t);
static void builtin_define_with_int_value (const char *, HOST_WIDE_INT); static void builtin_define_with_int_value (const char *, HOST_WIDE_INT);
static void builtin_define_with_hex_fp_value (const char *, tree, static void builtin_define_with_hex_fp_value (const char *, tree,
int, const char *, int, const char *,
...@@ -375,40 +373,17 @@ builtin_define_fixed_point_constants (const char *name_prefix, ...@@ -375,40 +373,17 @@ builtin_define_fixed_point_constants (const char *name_prefix,
static void static void
define__GNUC__ (void) define__GNUC__ (void)
{ {
/* The format of the version string, enforced below, is int major, minor, patchlevel;
([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)? */
const char *q, *v = version_string;
while (*v && !ISDIGIT (*v))
v++;
gcc_assert (*v && (v <= version_string || v[-1] == '-'));
q = v;
while (ISDIGIT (*v))
v++;
builtin_define_with_value_n ("__GNUC__", q, v - q);
if (c_dialect_cxx ())
builtin_define_with_value_n ("__GNUG__", q, v - q);
gcc_assert (*v == '.' && ISDIGIT (v[1]));
q = ++v; if (sscanf (BASEVER, "%d.%d.%d", &major, &minor, &patchlevel) != 3)
while (ISDIGIT (*v))
v++;
builtin_define_with_value_n ("__GNUC_MINOR__", q, v - q);
if (*v == '.')
{ {
gcc_assert (ISDIGIT (v[1])); sscanf (BASEVER, "%d.%d", &major, &minor);
q = ++v; patchlevel = 0;
while (ISDIGIT (*v))
v++;
builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", q, v - q);
} }
else cpp_define_formatted (parse_in, "__GNUC__=%d", major);
builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", "0", 1); cpp_define_formatted (parse_in, "__GNUC_MINOR__=%d", minor);
cpp_define_formatted (parse_in, "__GNUC_PATCHLEVEL__=%d", patchlevel);
gcc_assert (!*v || *v == ' ' || *v == '-');
} }
/* Define macros used by <stdint.h>. Currently only defines limits /* Define macros used by <stdint.h>. Currently only defines limits
...@@ -684,9 +659,6 @@ c_cpp_builtins (cpp_reader *pfile) ...@@ -684,9 +659,6 @@ c_cpp_builtins (cpp_reader *pfile)
if (flag_openmp) if (flag_openmp)
cpp_define (pfile, "_OPENMP=200505"); cpp_define (pfile, "_OPENMP=200505");
if (lang_fortran)
cpp_define (pfile, "__GFORTRAN__=1");
builtin_define_type_sizeof ("__SIZEOF_INT__", integer_type_node); builtin_define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
builtin_define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node); builtin_define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__", builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__",
...@@ -799,23 +771,6 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str) ...@@ -799,23 +771,6 @@ builtin_define_with_value (const char *macro, const char *expansion, int is_str)
cpp_define (parse_in, buf); cpp_define (parse_in, buf);
} }
/* Pass an object-like macro and a value to define it to. The third
parameter is the length of the expansion. */
static void
builtin_define_with_value_n (const char *macro, const char *expansion, size_t elen)
{
char *buf;
size_t mlen = strlen (macro);
/* Space for an = and a NUL. */
buf = (char *) alloca (mlen + elen + 2);
memcpy (buf, macro, mlen);
buf[mlen] = '=';
memcpy (buf + mlen + 1, expansion, elen);
buf[mlen + elen + 1] = '\0';
cpp_define (parse_in, buf);
}
/* Pass an object-like macro and an integer value to define it to. */ /* Pass an object-like macro and an integer value to define it to. */
static void static void
......
...@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h" #include "diagnostic.h"
#include "intl.h" #include "intl.h"
#include "cppdefault.h" #include "cppdefault.h"
#include "c-incpath.h" #include "incpath.h"
#include "debug.h" /* For debug_hooks. */ #include "debug.h" /* For debug_hooks. */
#include "opts.h" #include "opts.h"
#include "options.h" #include "options.h"
...@@ -72,9 +72,6 @@ static bool deps_seen; ...@@ -72,9 +72,6 @@ static bool deps_seen;
/* If -v seen. */ /* If -v seen. */
static bool verbose; static bool verbose;
/* If -lang-fortran seen. */
bool lang_fortran = false;
/* Dependency output file. */ /* Dependency output file. */
static const char *deps_file; static const char *deps_file;
...@@ -249,15 +246,6 @@ c_common_init_options (unsigned int argc, const char **argv) ...@@ -249,15 +246,6 @@ c_common_init_options (unsigned int argc, const char **argv)
result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX; result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
break; break;
} }
#ifdef CL_Fortran
for (i = 1; i < argc; i++)
if (! strcmp (argv[i], "-lang-fortran"))
{
result |= CL_Fortran;
break;
}
#endif
} }
return result; return result;
...@@ -288,10 +276,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -288,10 +276,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
result = 0; result = 0;
break; break;
} }
#ifdef CL_Fortran
if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
break;
#endif
result = 0; result = 0;
break; break;
...@@ -891,10 +875,6 @@ c_common_handle_option (size_t scode, const char *arg, int value) ...@@ -891,10 +875,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
cpp_opts->dollars_in_ident = false; cpp_opts->dollars_in_ident = false;
break; break;
case OPT_lang_fortran:
lang_fortran = true;
break;
case OPT_lang_objc: case OPT_lang_objc:
cpp_opts->objc = 1; cpp_opts->objc = 1;
break; break;
......
...@@ -864,9 +864,6 @@ C ObjC C++ ObjC++ Joined Separate ...@@ -864,9 +864,6 @@ C ObjC C++ ObjC++ Joined Separate
lang-asm lang-asm
C Undocumented C Undocumented
lang-fortran
C Undocumented
lang-objc lang-objc
C ObjC C++ ObjC++ Undocumented C ObjC C++ ObjC++ Undocumented
......
2008-05-26 Daniel Franke <franke.daniel@gmail.com>
* Makefile.in: Adjusted dependencies on c-incpath.o.
2008-05-23 Jakub Jelinek <jakub@redhat.com> 2008-05-23 Jakub Jelinek <jakub@redhat.com>
PR c++/36237 PR c++/36237
......
...@@ -72,7 +72,7 @@ g++-cross$(exeext): g++$(exeext) ...@@ -72,7 +72,7 @@ g++-cross$(exeext): g++$(exeext)
# Shared with C front end: # Shared with C front end:
CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \ CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \ c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \
c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \
c-gimplify.o c-omp.o tree-inline.o c-gimplify.o c-omp.o tree-inline.o
# Language-specific object files for C++ and Objective C++. # Language-specific object files for C++ and Objective C++.
......
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
#include "obstack.h" #include "obstack.h"
#include "scan.h" #include "scan.h"
#include "cpplib.h" #include "cpplib.h"
#include "c-incpath.h" #include "incpath.h"
#include "errors.h" #include "errors.h"
#ifdef TARGET_EXTRA_INCLUDES #ifdef TARGET_EXTRA_INCLUDES
......
2008-05-26 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, nocpp, 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.
* gfortran.texi: Updated section "Preprocessing and
conditional compilation".
* invoke.texi: Added new section "Preprocessing Options",
listed and documented the preprocessing options handled
by gfortran.
2008-05-25 Tobias Burnus <burnus@net-b.de> 2008-05-25 Tobias Burnus <burnus@net-b.de>
PR fortran/32600 PR fortran/32600
......
...@@ -53,9 +53,9 @@ fortran-warn = $(STRICT_WARN) ...@@ -53,9 +53,9 @@ fortran-warn = $(STRICT_WARN)
# from the parse tree to GENERIC # from the parse tree to GENERIC
F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \ F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \
fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse-tree.o \ fortran/check.o fortran/cpp.o fortran/data.o fortran/decl.o \
fortran/error.o fortran/expr.o fortran/interface.o \ fortran/dump-parse-tree.o fortran/error.o fortran/expr.o \
fortran/intrinsic.o fortran/io.o fortran/iresolve.o \ fortran/interface.o fortran/intrinsic.o fortran/io.o fortran/iresolve.o \
fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \ fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \
fortran/openmp.o fortran/options.o fortran/parse.o fortran/primary.o \ fortran/openmp.o fortran/options.o fortran/parse.o fortran/primary.o \
fortran/resolve.o fortran/scanner.o fortran/simplify.o fortran/st.o \ fortran/resolve.o fortran/scanner.o fortran/simplify.o fortran/st.o \
...@@ -306,9 +306,9 @@ GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/libgfortran.h \ ...@@ -306,9 +306,9 @@ GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/libgfortran.h \
$(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H) $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \ fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) \ gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) fortran/cpp.h \
$(BUILTINS_DEF) fortran/types.def $(BUILTINS_DEF) fortran/types.def
fortran/scanner.o: toplev.h fortran/scanner.o: toplev.h fortran/cpp.h
fortran/convert.o: $(GFORTRAN_TRANS_DEPS) fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
fortran/trans.o: $(GFORTRAN_TRANS_DEPS) fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \ fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
...@@ -329,4 +329,7 @@ fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h ...@@ -329,4 +329,7 @@ fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H) fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H)
fortran/resolve.o: fortran/dependency.h fortran/data.h fortran/target-memory.h fortran/resolve.o: fortran/dependency.h fortran/data.h fortran/target-memory.h
fortran/data.o: fortran/data.h fortran/data.o: fortran/data.h
fortran/options.o: $(PARAMS_H) $(TARGET_H) fortran/options.o: $(PARAMS_H) $(TARGET_H) fortran/cpp.h
fortran/cpp.o: fortran/cpp.c $(BASEVER) incpath.h incpath.o
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) -DBASEVER=$(BASEVER_s) \
$< $(OUTPUT_OPTION)
#ifndef GFC_CPP_H
#define GFC_CPP_H
/* Returns true if preprocessing is enabled, false otherwise. */
bool gfc_cpp_enabled (void);
bool gfc_cpp_preprocess_only (void);
const char *gfc_cpp_temporary_file (void);
void gfc_cpp_init_0 (void);
void gfc_cpp_init (void);
void gfc_cpp_init_options (unsigned int argc, const char **argv);
int gfc_cpp_handle_option(size_t scode, const char *arg, int value);
void gfc_cpp_post_options (void);
try gfc_cpp_preprocess (const char *source_file);
void gfc_cpp_done (void);
void gfc_cpp_add_include_path (char *path, bool user_supplied);
void gfc_cpp_register_include_paths (void);
#endif /* GFC_CPP_H */
...@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see
#include "cgraph.h" #include "cgraph.h"
#include "gfortran.h" #include "gfortran.h"
#include "cpp.h"
#include "trans.h" #include "trans.h"
#include "trans-types.h" #include "trans-types.h"
#include "trans-const.h" #include "trans-const.h"
...@@ -275,18 +276,25 @@ gfc_be_parse_file (int set_yydebug ATTRIBUTE_UNUSED) ...@@ -275,18 +276,25 @@ gfc_be_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
static bool static bool
gfc_init (void) gfc_init (void)
{ {
linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1); if (!gfc_cpp_enabled ())
linemap_add (line_table, LC_RENAME, false, "<built-in>", 0); {
linemap_add (line_table, LC_ENTER, false, gfc_source_file, 1);
linemap_add (line_table, LC_RENAME, false, "<built-in>", 0);
}
else
gfc_cpp_init_0 ();
/* First initialize the backend. */
gfc_init_decl_processing (); gfc_init_decl_processing ();
gfc_static_ctors = NULL_TREE; gfc_static_ctors = NULL_TREE;
/* Then the frontend. */ if (gfc_cpp_enabled ())
gfc_cpp_init ();
gfc_init_1 (); gfc_init_1 ();
if (gfc_new_file () != SUCCESS) if (gfc_new_file () != SUCCESS)
fatal_error ("can't open input file: %s", gfc_source_file); fatal_error ("can't open input file: %s", gfc_source_file);
return true; return true;
} }
...@@ -294,6 +302,7 @@ gfc_init (void) ...@@ -294,6 +302,7 @@ gfc_init (void)
static void static void
gfc_finish (void) gfc_finish (void)
{ {
gfc_cpp_done ();
gfc_done_1 (); gfc_done_1 ();
gfc_release_include_path (); gfc_release_include_path ();
return; return;
......
...@@ -408,11 +408,11 @@ through a C preprocessor (CPP; sometimes also called the Fortran preprocessor, ...@@ -408,11 +408,11 @@ through a C preprocessor (CPP; sometimes also called the Fortran preprocessor,
FPP) to allow for conditional compilation. In the case of GNU Fortran, FPP) to allow for conditional compilation. In the case of GNU Fortran,
this is the GNU C Preprocessor in the traditional mode. On systems with this is the GNU C Preprocessor in the traditional mode. On systems with
case-preserving file names, the preprocessor is automatically invoked if the case-preserving file names, the preprocessor is automatically invoked if the
file extension is @code{.F}, @code{.FOR}, @code{.FTN}, @code{.F90}, filename extension is @code{.F}, @code{.FOR}, @code{.FTN}, @code{.fpp},
@code{.F95}, @code{.F03} or @code{.F08}; otherwise use for fixed-format @code{.FPP}, @code{.F90}, @code{.F95}, @code{.F03} or @code{.F08}. To manually
code the option @code{-x f77-cpp-input} and for free-format code @code{-x invoke the preprocessor on any file, use @option{-cpp}, to disable
f95-cpp-input}. Invocation of the preprocessor can be suppressed using preprocessing on files where the preprocessor is run automatically, use
@code{-x f77} or @code{-x f95}. @option{-nocpp}.
If the GNU Fortran invoked the preprocessor, @code{__GFORTRAN__} If the GNU Fortran invoked the preprocessor, @code{__GFORTRAN__}
is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and
......
...@@ -20,35 +20,45 @@ ...@@ -20,35 +20,45 @@
/* This is the contribution to the `default_compilers' array in gcc.c /* This is the contribution to the `default_compilers' array in gcc.c
for the f95 language. */ for the f95 language. */
#define F951_CPP_OPTIONS "%{!nocpp: -cpp %g.f90 %(cpp_options)\
%{E|M|MM:%(cpp_debug_options) -fsyntax-only} %{E}}"
#define F951_OPTIONS "%(cc1_options) %{J*} %{I*}\
%{!nostdinc:-fintrinsic-modules-path finclude%s}\
%{!fsyntax-only:%(invoke_as)}"
#define F951_SOURCE_FORM "%{!ffree-form:-ffixed-form}"
{".F", "@f77-cpp-input", 0, 0, 0}, {".F", "@f77-cpp-input", 0, 0, 0},
{".FOR", "@f77-cpp-input", 0, 0, 0}, {".FOR", "@f77-cpp-input", 0, 0, 0},
{".FTN", "@f77-cpp-input", 0, 0, 0}, {".FTN", "@f77-cpp-input", 0, 0, 0},
{".fpp", "@f77-cpp-input", 0, 0, 0}, {".fpp", "@f77-cpp-input", 0, 0, 0},
{".FPP", "@f77-cpp-input", 0, 0, 0}, {".FPP", "@f77-cpp-input", 0, 0, 0},
{"@f77-cpp-input", {"@f77-cpp-input",
"cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \ "f951 %i " F951_SOURCE_FORM " " \
%{E|M|MM:%(cpp_debug_options)}\ F951_CPP_OPTIONS " %{!E:" F951_OPTIONS "}", 0, 0, 0},
%{!M:%{!MM:%{!E: -o %|.f |\n\ {".f", "@f77", 0, 0, 0},
f951 %|.f %{!ffree-form:-ffixed-form} %(cc1_options) %{J*} %{I*}\ {".for", "@f77", 0, 0, 0},
-fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, {".ftn", "@f77", 0, 0, 0},
{"@f77",
"f951 %i " F951_SOURCE_FORM " \
%{E:%{!cpp:%egfortran does not support -E without -cpp}} \
%{cpp:" F951_CPP_OPTIONS "} %{!E:" F951_OPTIONS "}", 0, 0, 0},
{".F90", "@f95-cpp-input", 0, 0, 0}, {".F90", "@f95-cpp-input", 0, 0, 0},
{".F95", "@f95-cpp-input", 0, 0, 0}, {".F95", "@f95-cpp-input", 0, 0, 0},
{".F03", "@f95-cpp-input", 0, 0, 0}, {".F03", "@f95-cpp-input", 0, 0, 0},
{".F08", "@f95-cpp-input", 0, 0, 0}, {".F08", "@f95-cpp-input", 0, 0, 0},
{"@f95-cpp-input", {"@f95-cpp-input",
"cc1 -E -lang-fortran -traditional-cpp -D_LANGUAGE_FORTRAN %(cpp_options) \ "f951 %i " F951_CPP_OPTIONS " %{!E:" F951_OPTIONS "}", 0, 0, 0},
%{E|M|MM:%(cpp_debug_options)}\
%{!M:%{!MM:%{!E: -o %|.f95 |\n\
f951 %|.f95 %{!ffixed-form:-ffree-form} %(cc1_options) %{J*} %{I*}\
-fpreprocessed %{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
{".f90", "@f95", 0, 0, 0}, {".f90", "@f95", 0, 0, 0},
{".f95", "@f95", 0, 0, 0}, {".f95", "@f95", 0, 0, 0},
{".f03", "@f95", 0, 0, 0}, {".f03", "@f95", 0, 0, 0},
{".f08", "@f95", 0, 0, 0}, {".f08", "@f95", 0, 0, 0},
{"@f95", "%{!E:f951 %i %(cc1_options) %{J*} %{I*}\ {"@f95",
%{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}", 0, 0, 0}, "f951 %i %{E:%{!cpp:%egfortran does not support -E without -cpp}}\
{".f", "@f77", 0, 0, 0}, %{cpp:" F951_CPP_OPTIONS "} %{!E:" F951_OPTIONS "}", 0, 0, 0},
{".for", "@f77", 0, 0, 0},
{".ftn", "@f77", 0, 0, 0},
{"@f77", "%{!E:f951 %i %{!ffree-form:-ffixed-form} %(cc1_options) %{J*} %{I*}\ #undef F951_SOURCE_FORM
%{!nostdinc:-fintrinsic-modules-path finclude%s} %{!fsyntax-only:%(invoke_as)}}", 0, 0, 0}, #undef F951_CPP_OPTIONS
#undef F951_OPTIONS
...@@ -25,6 +25,29 @@ ...@@ -25,6 +25,29 @@
Language Language
Fortran Fortran
A
Fortran Joined Separate
; Documented in C
C
Fortran
; Documented in C
CC
Fortran
; Documented in C
D
Fortran Joined Separate
; Documented in C
E
Fortran Undocumented
H
Fortran
; Documented in C
I I
Fortran Joined Separate Fortran Joined Separate
-I<directory> Add a directory for INCLUDE and MODULE searching -I<directory> Add a directory for INCLUDE and MODULE searching
...@@ -33,6 +56,14 @@ J ...@@ -33,6 +56,14 @@ J
Fortran Joined Separate Fortran Joined Separate
-J<directory> Put MODULE files in 'directory' -J<directory> Put MODULE files in 'directory'
P
Fortran
; Documented in C
U
Fortran Joined Separate
; Documented in C
Wall Wall
Fortran Fortran
; Documented in C ; Documented in C
...@@ -81,6 +112,18 @@ Wunderflow ...@@ -81,6 +112,18 @@ Wunderflow
Fortran Warning Fortran Warning
Warn about underflow of numerical constant expressions Warn about underflow of numerical constant expressions
cpp
Fortran Joined Separate Negative(nocpp)
Enable preprocessing
nocpp
Fortran Negative(cpp)
Disable preprocessing
d
Fortran Joined
-d[DIMNU] Dump details about macro names and definitions during preprocessing
fall-intrinsics fall-intrinsics
Fortran RejectNegative Fortran RejectNegative
All intrinsics procedures are available regardless of selected standard All intrinsics procedures are available regardless of selected standard
...@@ -289,6 +332,38 @@ funderscoring ...@@ -289,6 +332,38 @@ funderscoring
Fortran Fortran
Append underscores to externally visible names Append underscores to externally visible names
fworking-directory
Fortran
; Documented in C
imultilib
Fortran Joined Separate
; Documented in C
iprefix
Fortran Joined Separate
; Documented in C
iquote
Fortran Joined Separate
; Documented in C
isysroot
Fortran Joined Separate
; Documented in C
isystem
Fortran Joined Separate
; Documented in C
nostdinc
Fortran
; Documented in C
o
Fortran Joined Separate
; Documented in common.opt
static-libgfortran static-libgfortran
Fortran Fortran
Statically link the GNU Fortran helper library (libgfortran) Statically link the GNU Fortran helper library (libgfortran)
...@@ -313,4 +388,12 @@ std=legacy ...@@ -313,4 +388,12 @@ std=legacy
Fortran Fortran
Accept extensions to support legacy code Accept extensions to support legacy code
undef
Fortran
; Documented in C
v
Fortran
; Documented in C
; This comment is to ensure we retain the blank line above. ; This comment is to ensure we retain the blank line above.
...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-inline.h" #include "tree-inline.h"
#include "gfortran.h" #include "gfortran.h"
#include "target.h" #include "target.h"
#include "cpp.h"
gfc_option_t gfc_option; gfc_option_t gfc_option;
...@@ -50,8 +51,7 @@ set_default_std_flags (void) ...@@ -50,8 +51,7 @@ set_default_std_flags (void)
/* Get ready for options handling. */ /* Get ready for options handling. */
unsigned int unsigned int
gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, gfc_init_options (unsigned int argc, const char **argv)
const char **argv ATTRIBUTE_UNUSED)
{ {
gfc_source_file = NULL; gfc_source_file = NULL;
gfc_option.module_dir = NULL; gfc_option.module_dir = NULL;
...@@ -128,6 +128,9 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED, ...@@ -128,6 +128,9 @@ gfc_init_options (unsigned int argc ATTRIBUTE_UNUSED,
/* -fshort-enums can be default on some targets. */ /* -fshort-enums can be default on some targets. */
gfc_option.fshort_enums = targetm.default_short_enums (); gfc_option.fshort_enums = targetm.default_short_enums ();
/* Initialize cpp-related options. */
gfc_cpp_init_options(argc, argv);
return CL_Fortran; return CL_Fortran;
} }
...@@ -354,6 +357,15 @@ gfc_post_options (const char **pfilename) ...@@ -354,6 +357,15 @@ gfc_post_options (const char **pfilename)
if (gfc_option.flag_all_intrinsics) if (gfc_option.flag_all_intrinsics)
gfc_option.warn_nonstd_intrinsics = 0; gfc_option.warn_nonstd_intrinsics = 0;
gfc_cpp_post_options ();
/* FIXME: return gfc_cpp_preprocess_only ();
The return value of this function indicates whether the
backend needs to be initialized. On -E, we don't need
the backend. However, if we return 'true' here, an
ICE occurs. Initializing the backend doesn't hurt much,
hence, for now we can live with it as is. */
return false; return false;
} }
...@@ -452,6 +464,9 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -452,6 +464,9 @@ gfc_handle_option (size_t scode, const char *arg, int value)
if (code == N_OPTS) if (code == N_OPTS)
return 1; return 1;
if (gfc_cpp_handle_option (scode, arg, value) == 1)
return 1;
switch (code) switch (code)
{ {
default: default:
...@@ -692,7 +707,7 @@ gfc_handle_option (size_t scode, const char *arg, int value) ...@@ -692,7 +707,7 @@ gfc_handle_option (size_t scode, const char *arg, int value)
else else
gfc_fatal_error ("Unrecognized option to -finit-real: %s", gfc_fatal_error ("Unrecognized option to -finit-real: %s",
arg); arg);
break; break;
case OPT_finit_integer_: case OPT_finit_integer_:
gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON; gfc_option.flag_init_integer = GFC_INIT_INTEGER_ON;
......
...@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see
#include "toplev.h" #include "toplev.h"
#include "debug.h" #include "debug.h"
#include "flags.h" #include "flags.h"
#include "cpp.h"
/* Structure for holding module and include file search path. */ /* Structure for holding module and include file search path. */
typedef struct gfc_directorylist typedef struct gfc_directorylist
...@@ -340,6 +341,7 @@ void ...@@ -340,6 +341,7 @@ void
gfc_add_include_path (const char *path, bool use_for_modules) gfc_add_include_path (const char *path, bool use_for_modules)
{ {
add_path_to_list (&include_dirs, path, use_for_modules); add_path_to_list (&include_dirs, path, use_for_modules);
gfc_cpp_add_include_path (xstrdup(path), true);
} }
...@@ -1909,7 +1911,14 @@ gfc_new_file (void) ...@@ -1909,7 +1911,14 @@ gfc_new_file (void)
{ {
try result; try result;
result = load_file (gfc_source_file, true); if (gfc_cpp_enabled ())
{
result = gfc_cpp_preprocess (gfc_source_file);
if (!gfc_cpp_preprocess_only ())
result = load_file (gfc_cpp_temporary_file (), true);
}
else
result = load_file (gfc_source_file, true);
gfc_current_locus.lb = line_head; gfc_current_locus.lb = line_head;
gfc_current_locus.nextc = (line_head == NULL) ? NULL : line_head->line; gfc_current_locus.nextc = (line_head == NULL) ? NULL : line_head->line;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "cpplib.h" #include "cpplib.h"
#include "prefix.h" #include "prefix.h"
#include "intl.h" #include "intl.h"
#include "c-incpath.h" #include "incpath.h"
#include "cppdefault.h" #include "cppdefault.h"
/* Windows does not natively support inodes, and neither does MSDOS. /* Windows does not natively support inodes, and neither does MSDOS.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment