(opts_concat): New prototype.
(opts_obstack): New declaration.
* opts.c (opts_concat): New function.
(opts_obstack): New variable.
(init_options_struct): Call gcc_init_obstack on opts_obstack.
(finish_options): Use opts_concat instead of concat
and XOBNEWVEC instead of XNEWVEC.
* opts-common.c (generate_canonical_option, decode_cmdline_option,
generate_option): Likewise.
* Makefile.in (OPTS_H): Depend on $(OBSTACK_H).
* lto-wrapper.c (main): Call gcc_init_obstack on opts_obstack.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196305
138bc75d-0d04-0410-961f-
82ee72b054a4
2013-02-27 Jakub Jelinek <jakub@redhat.com>
+ * opts.h: Include obstack.h.
+ (opts_concat): New prototype.
+ (opts_obstack): New declaration.
+ * opts.c (opts_concat): New function.
+ (opts_obstack): New variable.
+ (init_options_struct): Call gcc_init_obstack on opts_obstack.
+ (finish_options): Use opts_concat instead of concat
+ and XOBNEWVEC instead of XNEWVEC.
+ * opts-common.c (generate_canonical_option, decode_cmdline_option,
+ generate_option): Likewise.
+ * Makefile.in (OPTS_H): Depend on $(OBSTACK_H).
+ * lto-wrapper.c (main): Call gcc_init_obstack on opts_obstack.
+
PR target/56455
* stmt.c (expand_switch_as_decision_tree_p): If flag_pic
and ASM_OUTPUT_ADDR_DIFF_ELT isn't defined, return true.
CPPLIB_H = $(srcdir)/../libcpp/include/line-map.h \
$(srcdir)/../libcpp/include/cpplib.h
INPUT_H = $(srcdir)/../libcpp/include/line-map.h input.h
-OPTS_H = $(INPUT_H) $(VEC_H) opts.h
+OPTS_H = $(INPUT_H) $(VEC_H) opts.h $(OBSTACK_H)
DECNUM_H = $(DECNUM)/decContext.h $(DECNUM)/decDPD.h $(DECNUM)/decNumber.h \
$(DECNUMFMT)/decimal32.h $(DECNUMFMT)/decimal64.h \
$(DECNUMFMT)/decimal128.h $(DECNUMFMT)/decimal128Local.h
{
const char *p;
+ gcc_obstack_init (&opts_obstack);
+
p = argv[0] + strlen (argv[0]);
while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
--p;
&& !option->cl_reject_negative
&& (opt_text[1] == 'W' || opt_text[1] == 'f' || opt_text[1] == 'm'))
{
- char *t = XNEWVEC (char, option->opt_len + 5);
+ char *t = XOBNEWVEC (&opts_obstack, char, option->opt_len + 5);
t[0] = '-';
t[1] = opt_text[1];
t[2] = 'n';
else
{
gcc_assert (option->flags & CL_JOINED);
- decoded->canonical_option[0] = concat (opt_text, arg, NULL);
+ decoded->canonical_option[0] = opts_concat (opt_text, arg, NULL);
decoded->canonical_option[1] = NULL;
decoded->canonical_option_num_elements = 1;
- if (opt_text != option->opt_text)
- free (CONST_CAST (char *, opt_text));
}
}
else
{
size_t j;
size_t len = strlen (arg);
- char *arg_lower = XNEWVEC (char, len + 1);
+ char *arg_lower = XOBNEWVEC (&opts_obstack, char, len + 1);
for (j = 0; j < len; j++)
arg_lower[j] = TOLOWER ((unsigned char) arg[j]);
decoded->canonical_option_num_elements = result;
}
}
- decoded->orig_option_with_args_text = p = XNEWVEC (char, total_len);
+ decoded->orig_option_with_args_text
+ = p = XOBNEWVEC (&opts_obstack, char, total_len);
for (i = 0; i < result; i++)
{
size_t len = strlen (argv[i]);
case 2:
decoded->orig_option_with_args_text
- = concat (decoded->canonical_option[0], " ",
- decoded->canonical_option[1], NULL);
+ = opts_concat (decoded->canonical_option[0], " ",
+ decoded->canonical_option[1], NULL);
break;
default:
*pvec = v;
}
+/* Like libiberty concat, but allocate using opts_obstack. */
+
+char *
+opts_concat (const char *first, ...)
+{
+ char *newstr, *end;
+ size_t length = 0;
+ const char *arg;
+ va_list ap;
+
+ /* First compute the size of the result and get sufficient memory. */
+ va_start (ap, first);
+ for (arg = first; arg; arg = va_arg (ap, const char *))
+ length += strlen (arg);
+ newstr = XOBNEWVEC (&opts_obstack, char, length + 1);
+ va_end (ap);
+
+ /* Now copy the individual pieces to the result string. */
+ va_start (ap, first);
+ for (arg = first, end = newstr; arg; arg = va_arg (ap, const char *))
+ {
+ length = strlen (arg);
+ memcpy (end, arg, length);
+ end += length;
+ }
+ *end = '\0';
+ va_end (ap);
+ return newstr;
+}
+
+/* Obstack for option strings. */
+
+struct obstack opts_obstack;
+
/* Initialize OPTS and OPTS_SET before using them in parsing options. */
void
{
size_t num_params = get_num_compiler_params ();
+ gcc_obstack_init (&opts_obstack);
+
*opts = global_options_init;
memset (opts_set, 0, sizeof (*opts_set));
directory, typically the directory to contain the object
file. */
if (opts->x_dump_dir_name)
- opts->x_dump_base_name = concat (opts->x_dump_dir_name,
- opts->x_dump_base_name, NULL);
+ opts->x_dump_base_name = opts_concat (opts->x_dump_dir_name,
+ opts->x_dump_base_name, NULL);
else if (opts->x_aux_base_name
&& strcmp (opts->x_aux_base_name, HOST_BIT_BUCKET) != 0)
{
if (opts->x_aux_base_name != aux_base)
{
int dir_len = aux_base - opts->x_aux_base_name;
- char *new_dump_base_name =
- XNEWVEC (char, strlen (opts->x_dump_base_name) + dir_len + 1);
+ char *new_dump_base_name
+ = XOBNEWVEC (&opts_obstack, char,
+ strlen (opts->x_dump_base_name) + dir_len + 1);
/* Copy directory component from OPTS->X_AUX_BASE_NAME. */
memcpy (new_dump_base_name, opts->x_aux_base_name, dir_len);
#include "input.h"
#include "vec.h"
+#include "obstack.h"
/* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */
enum cl_var_type {
extern unsigned num_in_fnames;
+extern char *opts_concat (const char *first, ...);
+
+/* Obstack for option strings. */
+
+extern struct obstack opts_obstack;
+
size_t find_opt (const char *input, unsigned int lang_mask);
extern int integral_argument (const char *arg);
extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args,