aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/misc.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-07-27 10:59:51 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2010-07-27 10:59:51 +0100
commit7a9bf9a4e0fdbf96ac988e149941e24f13e97b8d (patch)
treecb22bfd268b7388c3f8e1f2942cb855aada62993 /gcc/ada/gcc-interface/misc.c
parent42694189bdade115459859e898e0b78d1cdb033c (diff)
downloadgcc-7a9bf9a4e0fdbf96ac988e149941e24f13e97b8d.zip
gcc-7a9bf9a4e0fdbf96ac988e149941e24f13e97b8d.tar.gz
gcc-7a9bf9a4e0fdbf96ac988e149941e24f13e97b8d.tar.bz2
langhooks-def.h (lhd_init_options, [...]): New.
* langhooks-def.h (lhd_init_options, LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P): New. (LANG_HOOKS_INIT_OPTIONS): Update default definition. (LANG_HOOKS_INITIALIZER): Add new hooks. * langhooks.c (lhd_init_options, lhd_complain_wrong_lang_p): New. * langhooks.h (struct lang_hooks): Add new hooks option_lang_mask and complain_wrong_lang_p. Update init_options prototype. * c-objc-common.c (c_initialize_diagnostics): First call c_common_initialize_diagnostics. * c-objc-common.h (LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define. * coretypes.h (struct cl_option, struct cl_decoded_option): Declare. * hooks.c (hook_uint_uint_constcharptrptr_0): Remove. (hook_uint_void_0): New. * hooks.h (hook_uint_uint_constcharptrptr_0): Remove. (hook_uint_void_0): New. * opts-common.c (decode_cmdline_option, decode_cmdline_options_to_array): Also fill in canonical_option field. * opts.c (complain_wrong_lang): Use langhook to determine whether to complain instead of special-casing LTO. (decode_options): Separate lang_mask determination with option_lang_mask hook from call of init_options hook. * opts.h (struct cl_decoded_option): Add canonical_option. ada: * gcc-interface/misc.c (gnat_option_lang_mask): New. (gnat_init_options): Update prototype. Reconstruct argv array from decoded options. c-family: * c-common.h (c_common_option_lang_mask, c_common_initialize_diagnostics, c_common_complain_wrong_lang_p): New. (c_common_init_options): Update prototype. * c-opts.c (c_common_option_lang_mask): New. (c_common_initialize_diagnostics): Split out of c_common_init_options. (accept_all_c_family_options, c_common_complain_wrong_lang_p): New. (c_common_init_options): Update prototype. Use decoded options in search for -lang-asm. cp: * cp-objcp-common.c (cxx_initialize_diagnostics): First call c_common_initialize_diagnostics. * cp-objcp-common.h (LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define. fortran: * cpp.c (gfc_cpp_init_options): Update prototype. Use number of decoded options in allocating deferred_opt. * cpp.h (gfc_cpp_init_options): Update prototype. * f95-lang.c (LANG_HOOKS_OPTION_LANG_MASK): Define. * gfortran.h (gfc_option_lang_mask): New. (gfc_init_options): Update prototype. * options.c (gfc_option_lang_mask): New. (gfc_init_options): Update prototype. Pass new arguments to gfc_cpp_init_options. java: * lang.c (java_option_lang_mask): New. (java_init_options): Update prototype. (LANG_HOOKS_OPTION_LANG_MASK): Define. lto: * lto-lang.c (lto_option_lang_mask, lto_complain_wrong_lang_p): New. (lto_init_options): Update prototype. (LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define. From-SVN: r162560
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r--gcc/ada/gcc-interface/misc.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index 8444e4f..43ed157 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -61,7 +61,9 @@
#include "gigi.h"
static bool gnat_init (void);
-static unsigned int gnat_init_options (unsigned int, const char **);
+static unsigned int gnat_option_lang_mask (void);
+static void gnat_init_options (unsigned int,
+ struct cl_decoded_option *);
static int gnat_handle_option (size_t, const char *, int, int);
static bool gnat_post_options (const char **);
static alias_set_type gnat_get_alias_set (tree);
@@ -85,6 +87,8 @@ static tree gnat_eh_personality (void);
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct tree_identifier)
#undef LANG_HOOKS_INIT
#define LANG_HOOKS_INIT gnat_init
+#undef LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK gnat_option_lang_mask
#undef LANG_HOOKS_INIT_OPTIONS
#define LANG_HOOKS_INIT_OPTIONS gnat_init_options
#undef LANG_HOOKS_HANDLE_OPTION
@@ -249,22 +253,43 @@ gnat_handle_option (size_t scode, const char *arg, int value,
return 1;
}
-/* Initialize for option processing. */
+/* Return language mask for option processing. */
static unsigned int
-gnat_init_options (unsigned int argc, const char **argv)
+gnat_option_lang_mask (void)
{
- gnat_argv = (char **) xmalloc (sizeof (argv[0]));
- gnat_argv[0] = xstrdup (argv[0]); /* name of the command */
- gnat_argc = 1;
+ return CL_Ada;
+}
+
+/* Initialize for option processing. */
+
+static void
+gnat_init_options (unsigned int decoded_options_count,
+ struct cl_decoded_option *decoded_options)
+{
+ /* Reconstruct an argv array for use of back_end.adb.
+
+ ??? back_end.adb should not rely on this; instead, it should work
+ with decoded options without such reparsing, to ensure
+ consistency in how options are decoded. */
+ unsigned int i;
+
+ save_argv = XNEWVEC (const char *, 2 * decoded_options_count + 1);
+ save_argc = 0;
+ for (i = 0; i < decoded_options_count; i++)
+ {
+ save_argv[save_argc++] = decoded_options[i].canonical_option[0];
+ if (decoded_options[i].canonical_option[1] != NULL)
+ save_argv[save_argc++] = decoded_options[i].canonical_option[1];
+ }
+ save_argv[save_argc] = NULL;
- save_argc = argc;
- save_argv = argv;
+ gnat_argv = (char **) xmalloc (sizeof (save_argv[0]));
+ gnat_argv[0] = xstrdup (save_argv[0]); /* name of the command */
+ gnat_argc = 1;
/* Uninitialized really means uninitialized in Ada. */
flag_zero_initialized_in_bss = 0;
-
- return CL_Ada;
}
/* Post-switch processing. */