From 0b774babfb8e8cee784cba061d245868e2e2d3aa Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 29 Dec 2018 17:43:02 +0000 Subject: [PATCH] cpp.c (gfc_cpp_init): Add pre-defined macros for INTEGER(1) INTEGER(2)... 2018-12-25 Steven G. Kargl * cpp.c (gfc_cpp_init): Add pre-defined macros for INTEGER(1) INTEGER(2), INTEGER(8) and INTEGER(16) if supported. Add pre-defined macros for REAL(10) and REAL(16) if available. * gfortran.texi: Document new macros. From-SVN: r267464 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/cpp.c | 22 ++++++++++++++++++++++ gcc/fortran/gfortran.texi | 10 +++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 827cd9622c1..e2600283363 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-12-29 Steven G. Kargl + + * cpp.c (gfc_cpp_init): Add pre-defined macros for INTEGER(1) + INTEGER(2), INTEGER(8) and INTEGER(16) if supported. Add pre-defined + macros for REAL(10) and REAL(16) if available. + * gfortran.texi: Document new macros. + 2018-12-27 Steven G. Kargl PR fortran/81027 diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index 95b08a91343..bf4d8912ba1 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -609,6 +609,28 @@ gfc_cpp_init (void) opt->arg, opt->code == OPT_MQ); } + /* Pre-defined macros for non-required INTEGER kind types. */ + for (gfc_integer_info *itype = gfc_integer_kinds; itype->kind != 0; itype++) + { + if (itype->kind == 1) + cpp_define (cpp_in, "__GFC_INT_1__=1"); + if (itype->kind == 2) + cpp_define (cpp_in, "__GFC_INT_2__=1"); + if (itype->kind == 8) + cpp_define (cpp_in, "__GFC_INT_8__=1"); + if (itype->kind == 16) + cpp_define (cpp_in, "__GFC_INT_16__=1"); + } + + /* Pre-defined macros for non-required REAL kind types. */ + for (gfc_real_info *rtype = gfc_real_kinds; rtype->kind != 0; rtype++) + { + if (rtype->kind == 10) + cpp_define (cpp_in, "__GFC_REAL_10__=1"); + if (rtype->kind == 16) + cpp_define (cpp_in, "__GFC_REAL_16__=1"); + } + if (gfc_cpp_option.working_directory && gfc_cpp_option.preprocess_only && !gfc_cpp_option.no_line_commands) pp_dir_change (cpp_in, get_src_pwd ()); diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index 8654601f4f6..60c5d5d4bfc 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -418,10 +418,18 @@ statement, the included file is not preprocessed. To preprocess included files, use the equivalent preprocessor statement @code{#include}. If GNU Fortran invokes the preprocessor, @code{__GFORTRAN__} -is defined and @code{__GNUC__}, @code{__GNUC_MINOR__} and +is defined. The macros @code{__GNUC__}, @code{__GNUC_MINOR__} and @code{__GNUC_PATCHLEVEL__} can be used to determine the version of the compiler. See @ref{Top,,Overview,cpp,The C Preprocessor} for details. +GNU Fortran supports a number of @code{INTEGER} and @code{REAL} kind types +in additional to the kind types required by the Fortran standard. +The availability of any given kind type is architecture dependent. The +following pre-defined preprocessor macros can be used to conditional +include code for these additional kind types: @code{__GFC_INTEGER_1__}, +@code{__GFC_INTEGER_2__}, @code{__GFC_INTEGER_8__}, @code{__GFC_INTEGER_16__}, +@code{__GFC_REAL_10__}, and @code{__GFC_REAL_16__}. + While CPP is the de-facto standard for preprocessing Fortran code, Part 3 of the Fortran 95 standard (ISO/IEC 1539-3:1998) defines Conditional Compilation, which is not widely used and not directly -- 2.30.2