This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch] Have cc1 define a __GFORTRAN__ macro when -lang-fortran is used
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Apr 2007 18:40:04 +0200
- Subject: [patch] Have cc1 define a __GFORTRAN__ macro when -lang-fortran is used
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=GHohbAkLAek0taxc/t6QKNzpjh3ckXrwMPvAJHNKpI7TCGijcRk549EX8DPjnkrEn9fjBdx75e1QT+o0TqlqhoWS6JO85ZHgNJCC6R/qO+TnVG8fKH365n7igXb8zXuD+Gk9H+K7G9kSBE5nzFXzIuWP9UHw21mzbt1q+9od9HY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=FlCA6JvhMP5SWQffFvi0Bt0SU7CvwmV61RxAIT5zoybOJXDInuFzbdArI+hGvHKfW+i+zHF95srQDIOJJalxlZ3STXn7U4PsrqTZ3oQA68ZlLtE18NXVc6ZBtHbw2UlSxxchda/xdlmqBSVomf5ABYquup5cp/+v+qtCCV2fQW4=
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;