diff options
author | Tobias Burnus <burnus@net-b.de> | 2010-09-28 21:51:38 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2010-09-28 21:51:38 +0200 |
commit | 41804a5be02d8d811e5189a9cca9060f41cea765 (patch) | |
tree | f3feddbb7172dda121a8dcfbdba67d925fe2b5df /gcc/fortran/options.c | |
parent | 770a498aeea017024d45dded87022d3f05bb27c9 (diff) | |
download | gcc-41804a5be02d8d811e5189a9cca9060f41cea765.zip gcc-41804a5be02d8d811e5189a9cca9060f41cea765.tar.gz gcc-41804a5be02d8d811e5189a9cca9060f41cea765.tar.bz2 |
re PR fortran/40569 (F2008: Support COMPILER_OPTIONS() / COMPILER_VERSION())
gcc/
2010-09-28 Tobias Burnus <burnus@net-b.de>
PR fortran/40569
PR fortran/40568
* toplev.h (save_decoded_options, save_decoded_options_count):
New global variables.
* toplev.c (save_decoded_options, save_decoded_options_count):
export variables.
gcc/fortran/
2010-09-28 Tobias Burnus <burnus@net-b.de>
PR fortran/40569
PR fortran/40568
* intrinsic.c (add_functions): Make compiler_version and
compiler_options CLASS_INQUIRY.
* gfortran.h (gfc_get_option_string): New prototype.
* intrinsic.texi (COMPILER_VERSION, COMPILER_OPTIONS):
Add documentation.
(C_SIZEOF): Mark as inquiry function of ISO_C_BINDING.
(ISO_FORTRAN_ENV): Refer to COMPILER_VERSION and COMPILER_OPTIONS.
(ISO_C_BINDING): Refer to C_SIZEOF.
* options.c (gfc_get_option_string): New function.
* simplify.c (gfc_simplify_compiler_options): Use it.
(gfc_simplify_compiler_version): Include compiler name.
From-SVN: r164698
Diffstat (limited to 'gcc/fortran/options.c')
-rw-r--r-- | gcc/fortran/options.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index c49620a..f7f76f4 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "intl.h" #include "opts.h" +#include "toplev.h" /* For save_decoded_options. */ #include "options.h" #include "params.h" #include "tree-inline.h" @@ -966,3 +967,79 @@ gfc_handle_option (size_t scode, const char *arg, int value, return result; } + + +/* Return a string with the options passed to the compiler; used for + Fortran's compiler_options() intrinsic. */ + +char * +gfc_get_option_string (void) +{ + unsigned j; + size_t len, pos; + char *result; + + /* Determine required string length. */ + + len = 0; + for (j = 1; j < save_decoded_options_count; j++) + { + switch (save_decoded_options[j].opt_index) + { + case OPT_o: + case OPT_d: + case OPT_dumpbase: + case OPT_dumpdir: + case OPT_auxbase: + case OPT_quiet: + case OPT_version: + case OPT_fintrinsic_modules_path: + /* Ignore these. */ + break; + default: + /* Ignore file names. */ + if (save_decoded_options[j].orig_option_with_args_text[0] == '-') + len += 1 + + strlen (save_decoded_options[j].orig_option_with_args_text); + } + } + + result = (char *) gfc_getmem (len); + + pos = 0; + for (j = 1; j < save_decoded_options_count; j++) + { + switch (save_decoded_options[j].opt_index) + { + case OPT_o: + case OPT_d: + case OPT_dumpbase: + case OPT_dumpdir: + case OPT_auxbase: + case OPT_quiet: + case OPT_version: + case OPT_fintrinsic_modules_path: + /* Ignore these. */ + continue; + + case OPT_cpp_: + /* Use "-cpp" rather than "-cpp=<temporary file>". */ + len = 4; + break; + + default: + /* Ignore file names. */ + if (save_decoded_options[j].orig_option_with_args_text[0] != '-') + continue; + + len = strlen (save_decoded_options[j].orig_option_with_args_text); + } + + memcpy (&result[pos], save_decoded_options[j].orig_option_with_args_text, len); + pos += len; + result[pos++] = ' '; + } + + result[--pos] = '\0'; + return result; +} |