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] Have cc1 define a __GFORTRAN__ macro when -lang-fortran is used


Hi all,

Attached patch makes cc1 define the __GFORTRAN__ macro as equal to 1
when it is passed the -lang-fortran option. This option is used when
the driver decides (or is told ) to preprocess a Fortran file. The
changes are minimal: we already had a lang_fortran variable that says
whether -lang-fortran was passed, so we simply need to make it visible
from c-cppbuiltin.c, where we actually define the macro.

The patch is bootstrapped with C and Fortran on i686-linux. An earlier
version regtested fine, and this regression-test for this one is
almost done.

OK for mainline?



2007-04-25 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>

       PR driver/31694
       * gcc/c-opts.c (lang_fortran): Make it non static.
       * gcc/c-common.h (lang_fortran): New prototype.
       * gcc/c-cppbuiltin.c (c_cpp_builtins): Create a __GFORTRAN__
       if the -lang-fortran option was passed by the driver.
Index: gcc/c-common.h
===================================================================
--- gcc/c-common.h	(revision 124144)
+++ gcc/c-common.h	(working copy)
@@ -254,6 +254,9 @@
 #define c_dialect_cxx()		(c_language & clk_cxx)
 #define c_dialect_objc()	(c_language & clk_objc)
 
+/* FXC */
+extern bool lang_fortran;
+
 /* Information about a statement tree.  */
 
 struct stmt_tree_s GTY(()) {
Index: gcc/c-cppbuiltin.c
===================================================================
--- gcc/c-cppbuiltin.c	(revision 124144)
+++ gcc/c-cppbuiltin.c	(working copy)
@@ -569,6 +569,9 @@
   if (flag_openmp)
     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_LONG__", long_integer_type_node);
   builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__",
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c	(revision 124144)
+++ gcc/c-opts.c	(working copy)
@@ -73,7 +73,7 @@
 static bool verbose;
 
 /* If -lang-fortran seen.  */
-static bool lang_fortran = false;
+bool lang_fortran = false;
 
 /* Dependency output file.  */
 static const char *deps_file;

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