This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Constification patch (4/5)
- To: gcc-patches at gcc dot gnu dot org
- Subject: Constification patch (4/5)
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Tue, 9 May 2000 12:45:56 -0700
Constification patch, Fortran front end.
zw
* com.c (ffecom_subscript_check_): Constify array_name
parameter. Clean up string bashing.
(ffecom_arrayref_, ffecom_char_args_x_): Constify array_name
parameter.
(ffecom_do_entry_, ffecom_gen_sfuncdef_, ffecom_start_progunit_,
ffecom_sym_transform_, ffecom_sym_transform_assign_): Constify
local char *.
(init_parse): Constify parameter and return value.
* lex.c: Include dwarfout.h instead of prototyping dwarfout_*
functions here.
(ffelex_file_pop_, ffelex_file_push_): Constify filename parameter.
(ffelex_hash_, ffelex_include_): Constify local char *.
* std.c (ffestd_exec_end): Constify local char *.
* where.c (ffewhere_file_new): Constify filename parameter.
* where.h: Update prototypes.
===================================================================
Index: f/com.c
--- f/com.c 2000/05/06 17:29:59 1.84
+++ f/com.c 2000/05/08 20:16:54
@@ -712,7 +712,7 @@ static tree shadowed_labels;
static tree
ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
- char *array_name)
+ const char *array_name)
{
tree low = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
tree high = TYPE_MAX_VALUE (TYPE_DOMAIN (array));
@@ -762,31 +762,30 @@ ffecom_subscript_check_ (tree array, tre
{
case 0:
var = xmalloc (strlen (array_name) + 20);
- sprintf (&var[0], "%s[%s-substring]",
+ sprintf (var, "%s[%s-substring]",
array_name,
dim ? "end" : "start");
len = strlen (var) + 1;
+ arg1 = build_string (len, var);
+ free (var);
break;
case 1:
len = strlen (array_name) + 1;
- var = array_name;
+ arg1 = build_string (len, array_name);
break;
default:
var = xmalloc (strlen (array_name) + 40);
- sprintf (&var[0], "%s[subscript-%d-of-%d]",
+ sprintf (var, "%s[subscript-%d-of-%d]",
array_name,
dim + 1, total_dims);
len = strlen (var) + 1;
+ arg1 = build_string (len, var);
+ free (var);
break;
}
- arg1 = build_string (len, var);
-
- if (total_dims != 1)
- free (var);
-
TREE_TYPE (arg1)
= build_type_variant (build_array_type (char_type_node,
build_range_type
@@ -877,7 +876,7 @@ ffecom_arrayref_ (tree item, ffebld expr
tree element;
tree tree_type;
tree tree_type_x;
- char *array_name;
+ const char *array_name;
ffetype type;
ffebld list;
@@ -2072,7 +2071,7 @@ ffecom_char_args_x_ (tree *xitem, tree *
ffebld thing = ffebld_right (expr);
tree start_tree;
tree end_tree;
- char *char_name;
+ const char *char_name;
ffebld left_symter;
tree array;
@@ -2678,7 +2677,7 @@ ffecom_do_entry_ (ffesymbol fn, int entr
bool altreturning = FALSE; /* This entry point has alternate returns. */
int yes;
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
input_filename = ffesymbol_where_filename (fn);
lineno = ffesymbol_where_filelinenum (fn);
@@ -6262,7 +6261,7 @@ ffecom_gen_sfuncdef_ (ffesymbol s, ffein
static bool recurse = FALSE;
int yes;
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
ffecom_nested_entry_ = s;
@@ -7292,7 +7291,7 @@ ffecom_start_progunit_ ()
&& (ffecom_master_bt_ == FFEINFO_basictypeNONE);
bool main_program = FALSE;
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
int yes;
assert (fn != NULL);
@@ -7528,7 +7527,7 @@ ffecom_sym_transform_ (ffesymbol s)
ffeglobal g;
int yes;
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
/* Must ensure special ASSIGN variables are declared at top of outermost
block, else they'll end up in the innermost block when their first
@@ -8575,7 +8574,7 @@ ffecom_sym_transform_assign_ (ffesymbol
tree t; /* Transformed thingy. */
int yes;
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
if (ffesymbol_sfdummyparent (s) == NULL)
{
@@ -14770,9 +14769,9 @@ init_decl_processing ()
ffe_init_0 ();
}
-char *
+const char *
init_parse (filename)
- char *filename;
+ const char *filename;
{
/* Open input file. */
if (filename == 0 || !strcmp (filename, "-"))
===================================================================
Index: f/lex.c
--- f/lex.c 2000/04/18 22:34:13 1.17
+++ f/lex.c 2000/05/08 20:16:56
@@ -36,11 +36,8 @@ the Free Software Foundation, 59 Temple
#endif
#ifdef DWARF_DEBUGGING_INFO
-void dwarfout_resume_previous_source_file (register unsigned);
-void dwarfout_start_new_source_file (register char *);
-void dwarfout_define (register unsigned, register char *);
-void dwarfout_undef (register unsigned, register char *);
-#endif DWARF_DEBUGGING_INFO
+#include "dwarfout.h"
+#endif
static void ffelex_append_to_token_ (char c);
static int ffelex_backslash_ (int c, ffewhereColumnNumber col);
@@ -856,7 +853,7 @@ ffelex_cfelex_ (ffelexToken *xtoken, FIL
#if FFECOM_targetCURRENT == FFECOM_targetGCC
static void
-ffelex_file_pop_ (char *input_filename)
+ffelex_file_pop_ (const char *input_filename)
{
if (input_file_stack->next)
{
@@ -882,7 +879,7 @@ ffelex_file_pop_ (char *input_filename)
#endif
#if FFECOM_targetCURRENT == FFECOM_targetGCC
static void
-ffelex_file_push_ (int old_lineno, char *input_filename)
+ffelex_file_push_ (int old_lineno, const char *input_filename)
{
struct file_stack *p
= (struct file_stack *) xmalloc (sizeof (struct file_stack));
@@ -1282,7 +1279,7 @@ ffelex_hash_ (FILE *finput)
&& (ffelex_token_type (token) == FFELEX_typeNUMBER))
{
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
ffewhereFile wf;
/* subtract one, because it is the following line that
@@ -1554,7 +1551,7 @@ ffelex_include_ ()
= ffewhere_line_filelinenum (current_wl);
#if FFECOM_targetCURRENT == FFECOM_targetGCC
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
#endif
if (card_length != 0)
===================================================================
Index: f/std.c
--- f/std.c 1999/11/29 02:26:48 1.11
+++ f/std.c 2000/05/08 20:16:57
@@ -1500,7 +1500,7 @@ ffestd_exec_end ()
{
#if FFECOM_targetCURRENT == FFECOM_targetGCC
int old_lineno = lineno;
- char *old_input_filename = input_filename;
+ const char *old_input_filename = input_filename;
#endif
ffecom_end_transition ();
===================================================================
Index: f/where.c
--- f/where.c 2000/02/06 04:30:45 1.7
+++ f/where.c 2000/05/08 20:16:57
@@ -161,7 +161,7 @@ ffewhere_file_kill (ffewhereFile wf)
/* Create file object. */
ffewhereFile
-ffewhere_file_new (char *name, size_t length)
+ffewhere_file_new (const char *name, size_t length)
{
ffewhereFile wf;
int filepos;
===================================================================
Index: f/where.h
--- f/where.h 1999/02/15 18:18:16 1.4
+++ f/where.h 2000/05/08 20:16:59
@@ -89,7 +89,7 @@ extern struct _ffewhere_line_ ffewhere_u
/* Declare functions with prototypes. */
void ffewhere_file_kill (ffewhereFile wf);
-ffewhereFile ffewhere_file_new (char *name, size_t length);
+ffewhereFile ffewhere_file_new (const char *name, size_t length);
void ffewhere_file_set (ffewhereFile wf, bool have_num, ffewhereLineNumber ln);
void ffewhere_init_1 (void);
char *ffewhere_line_content (ffewhereLine l);