aboutsummaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@wolery.stanford.edu>2000-11-17 06:05:31 +0000
committerZack Weinberg <zack@gcc.gnu.org>2000-11-17 06:05:31 +0000
commit520a57c81c83affcccb71eef52da0278991af777 (patch)
tree925528b7b20608d2eac0acf5e939480048b49271 /gcc/stmt.c
parent5af655cceef2b8b61a323734a6f9c250b4f420ca (diff)
downloadgcc-520a57c81c83affcccb71eef52da0278991af777.zip
gcc-520a57c81c83affcccb71eef52da0278991af777.tar.gz
gcc-520a57c81c83affcccb71eef52da0278991af777.tar.bz2
stringpool.c: New file.
* stringpool.c: New file. * ggc-common.c (ggc_mark_string_ptr, ggc_add_string_root): Delete. (ggc_alloc_string): Now in stringpool.o. * ggc-page.c, ggc-simple.c: Do not define or allocate empty_string. * ggc.h: Delete prototype of ggc_add_string_root. #define ggc_add_string_root and ggc_mark_string to nothing. Prototype init_stringpool and stringpool_statistics. (ggc_alloc_string): Returns a const char *. * tree.c (hash_table, do_identifier_warnings): Delete. (init_obstacks): Don't initialize the identifier hash table. (get_identifier, maybe_get_identifier, start_identifier_warnings, set_identifier_size): Now in stringpool.c. * tree.h (struct tree_string): Constify pointer field. (approx_sqrt): Prototype. * Makefile.in (stringpool.o): Add rule, mention in OBJS. * toplev.c (approx_sqrt): New function. (compile_file): Call stringpool_statistics if mem_report is on. (main): Call init_stringpool. * builtins.c (c_strlen), c-decl.c (finish_decl), c-lex.c (process_directive), c-typeck.c (constructor_asmspec, struct initializer_stack, start_init), except.c (create_rethrow_ref), stmt.c (digit_strings), toplev.c (decode_f_option), tree.c (built_in_filename), varasm,c (in_named_name, assemble_static_space, struct constant_descriptor, struct deferred_string, struct pool_constant, force_const_mem), i386.c (pic_label_name, global_offset_table_name), rs6000.c (rs6000_emit_prologue, rs6000_emit_epilogue) : Constify a char *. * c-common.c (combine_strings): Combine strings in scratch buffer, then pass to build_string. * optabs.c (init_libfuncs), profile.c (init_edge_profiler, output_func_start_profiler), stmt.c (init_stmt), alpha.c (alpha_need_linkage), arm.c (arm_encode_call_attribute), i386.c (load_pic_register), ia64.c (ia64_encode_section_info), rs6000.c (rs6000_encode_section_info): Create string in scratch buffer, then pass to ggc_alloc_string. * stmt.c (expand_asm_operands): If we must adjust the constraint strings, do so by creating a new one, not by modifying the old one in place. Constify some char *s. * config/pa/pa.c (hppa_encode_label): Drop unnecessary second argument. Create string in scratch buffer, then pass to ggc_alloc_string. * config/pa/pa-protos.h: Update prototype. * config/pa/elf.h, config/pa/pa.h, config/pa/som.h: hppa_encode_label takes only one argument. * c-parse.in (if_prefix): Find the filename and line number at $-2 and $-1 respectively. * diagnostic.c (error_recursion): Add missing newline, use fputs, translate string. cp: * lex.c (struct impl_files, internal_filename): Constify a char *. java: * jcf-parse.c (get_constant), parse.y (do_merge_string_cste): Create string in scratch buffer, then pass to build_string. From-SVN: r37514
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 82a390d..4ec3fd5 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -394,7 +394,7 @@ struct stmt_status
static int using_eh_for_cleanups_p = 0;
/* Character strings, each containing a single decimal digit. */
-static char *digit_strings[10];
+static const char *digit_strings[10];
static int n_occurrences PARAMS ((int, const char *));
static void expand_goto_internal PARAMS ((tree, rtx, rtx));
@@ -598,13 +598,15 @@ void
init_stmt ()
{
int i;
+ char buf[2];
gcc_obstack_init (&stmt_obstack);
+ buf[1] = 0;
for (i = 0; i < 10; i++)
{
- digit_strings[i] = ggc_alloc_string (NULL, 1);
- digit_strings[i][0] = '0' + i;
+ buf[0] = '0' + i;
+ digit_strings[i] = ggc_alloc_string (buf, 1);
}
ggc_add_string_root (digit_strings, 10);
}
@@ -1408,7 +1410,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
{
tree val = TREE_VALUE (tail);
tree type = TREE_TYPE (val);
- char *constraint;
+ const char *constraint;
char *p;
int c_len;
int j;
@@ -1425,8 +1427,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
the worst that happens if we get it wrong is we issue an error
message. */
- c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (tail)));
constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
+ c_len = strlen (constraint);
/* Allow the `=' or `+' to not be at the beginning of the string,
since it wasn't explicitly documented that way, and there is a
@@ -1443,19 +1445,25 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
error ("output operand constraint lacks `='");
return;
}
+ j = p - constraint;
+ is_inout = *p == '+';
- if (p != constraint)
+ if (j || is_inout)
{
- j = *p;
- bcopy (constraint, constraint+1, p-constraint);
- *constraint = j;
-
- warning ("output constraint `%c' for operand %d is not at the beginning", j, i);
+ /* Have to throw away this constraint string and get a new one. */
+ char *buf = alloca (c_len + 1);
+ buf[0] = '=';
+ if (j)
+ memcpy (buf + 1, constraint, j);
+ memcpy (buf + 1 + j, p + 1, c_len - j); /* not -j-1 - copy null */
+ constraint = ggc_alloc_string (buf, c_len);
+
+ if (j)
+ warning (
+ "output constraint `%c' for operand %d is not at the beginning",
+ *p, i);
}
- is_inout = constraint[0] == '+';
- /* Replace '+' with '='. */
- constraint[0] = '=';
/* Make sure we can specify the matching operand. */
if (is_inout && i > 9)
{
@@ -1611,7 +1619,7 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
{
int j;
int allows_reg = 0, allows_mem = 0;
- char *constraint, *orig_constraint;
+ const char *constraint, *orig_constraint;
int c_len;
rtx op;
@@ -1629,8 +1637,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
return;
}
- c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (tail)));
constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
+ c_len = strlen (constraint);
orig_constraint = constraint;
/* Make sure constraint has neither `=', `+', nor '&'. */
@@ -1691,8 +1699,8 @@ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
for (j = constraint[j] - '0'; j > 0; --j)
o = TREE_CHAIN (o);
- c_len = strlen (TREE_STRING_POINTER (TREE_PURPOSE (o)));
constraint = TREE_STRING_POINTER (TREE_PURPOSE (o));
+ c_len = strlen (constraint);
j = 0;
break;
}