This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR 51808 Heap allocate binding labels
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Gerald Pfeifer <gerald at pfeifer dot com>
- Cc: Mikael Morin <mikael dot morin at sfr dot fr>, Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 2 Feb 2012 21:11:23 +0200
- Subject: Re: [Patch, fortran] PR 51808 Heap allocate binding labels
- References: <20120118091237.GA14022@physik.fu-berlin.de> <4F16BEDA.9050505@sfr.fr> <CAO9iq9GKaUj+PTzuH8a_40-eKJ83oyXuJuF=4FTm=K8UiCbMaQ@mail.gmail.com> <alpine.LNX.2.00.1201292233410.2227@gerinyyl.fvgr> <CAO9iq9G+RxE=P21LovpX_3eejVSxDLZ0PrWBXL8gjxfJbfR9uQ@mail.gmail.com> <alpine.LNX.2.00.1201310143450.2227@gerinyyl.fvgr>
On Tue, Jan 31, 2012 at 02:46, Gerald Pfeifer <gerald@pfeifer.com> wrote:
> On Sun, 29 Jan 2012, Janne Blomqvist wrote:
>>> .../gcc-HEAD/gcc/fortran/decl.c:5820:23: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
>>> gmake[3]: *** [fortran/decl.o] Error 1
>> Have you tried r183679, which should fix this?
>
> Yes, I now tried that update (my daily tester yesterday picked a state
> of the tree without that changeset) and bootstrap passed just fine. ÂI
> had actually looked for follow-up patches yesterday, but did not see
> any on the list (possibly missed it).
Ah, it seems that in my hurry I forgot to send in to the list. Here it
is for completeness:
2012-01-29 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/51808
* decl.c (set_binding_label): Make binding_label argument const.
(curr_binding_label): Constify.
* gfortran.h (gfc_symbol): Constify binding_label.
(gfc_common_head): Likewise.
(get_iso_c_sym): Likewise.
* match.c (gfc_match_name_C): Constify buffer argument.
* match.h (gfc_match_name_C): Likewise.
* resolve.c (set_name_and_label): Constify binding_label argument.
(gfc_iso_c_sub_interface): Constify binding_label variable.
* symbol.c (get_iso_c_sym): Constify binding_label argument.
--
Janne Blomqvist
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 0cfb0ef..c87fc1b 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3. If not see
#define gfc_get_data() XCNEW (gfc_data)
-static gfc_try set_binding_label (char **, const char *, int);
+static gfc_try set_binding_label (const char **, const char *, int);
/* This flag is set if an old-style length selector is matched
@@ -55,7 +55,7 @@ static gfc_array_spec *current_as;
static int colon_seen;
/* The current binding label (if any). */
-static char* curr_binding_label;
+static const char* curr_binding_label;
/* Need to know how many identifiers are on the current data declaration
line in case we're given the BIND(C) attribute with a NAME= specifier. */
static int num_idents_on_line;
@@ -3808,7 +3808,8 @@ cleanup:
there is more than one argument (num_idents), it is an error. */
static gfc_try
-set_binding_label (char **dest_label, const char *sym_name, int num_idents)
+set_binding_label (const char **dest_label, const char *sym_name,
+ int num_idents)
{
if (num_idents > 1 && has_name_equals)
{
@@ -5713,7 +5714,7 @@ match
gfc_match_bind_c (gfc_symbol *sym, bool allow_binding_name)
{
/* binding label, if exists */
- char* binding_label = NULL;
+ const char* binding_label = NULL;
match double_quote;
match single_quote;
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index bf9a1f9..6f49d61 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1237,7 +1237,7 @@ typedef struct gfc_symbol
/* This may be repetitive, since the typespec now has a binding
label field. */
- char* binding_label;
+ const char* binding_label;
/* Store a reference to the common_block, if this symbol is in one. */
struct gfc_common_head *common_block;
@@ -1254,7 +1254,7 @@ typedef struct gfc_common_head
char use_assoc, saved, threadprivate;
char name[GFC_MAX_SYMBOL_LEN + 1];
struct gfc_symbol *head;
- char* binding_label;
+ const char* binding_label;
int is_bind_c;
}
gfc_common_head;
@@ -2595,7 +2595,7 @@ gfc_try verify_bind_c_sym (gfc_symbol *, gfc_typespec *, int, gfc_common_head *)
gfc_try verify_bind_c_derived_type (gfc_symbol *);
gfc_try verify_com_block_vars_c_interop (gfc_common_head *);
void generate_isocbinding_symbol (const char *, iso_c_binding_symbol, const char *);
-gfc_symbol *get_iso_c_sym (gfc_symbol *, char *, char *, int);
+gfc_symbol *get_iso_c_sym (gfc_symbol *, char *, const char *, int);
int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **, bool);
int gfc_get_ha_symbol (const char *, gfc_symbol **);
int gfc_get_ha_sym_tree (const char *, gfc_symtree **);
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 3024cc7..89b59bc 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -581,7 +581,7 @@ gfc_match_name (char *buffer)
we successfully match a C name. */
match
-gfc_match_name_C (char **buffer)
+gfc_match_name_C (const char **buffer)
{
locus old_loc;
size_t i = 0;
diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h
index 642c437..029faf7 100644
--- a/gcc/fortran/match.h
+++ b/gcc/fortran/match.h
@@ -52,7 +52,7 @@ match gfc_match_label (void);
match gfc_match_small_int (int *);
match gfc_match_small_int_expr (int *, gfc_expr **);
match gfc_match_name (char *);
-match gfc_match_name_C (char **buffer);
+match gfc_match_name_C (const char **buffer);
match gfc_match_symbol (gfc_symbol **, int);
match gfc_match_sym_tree (gfc_symtree **, int);
match gfc_match_intrinsic_op (gfc_intrinsic_op *);
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 30980d2..0560261 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -3356,7 +3356,7 @@ generic:
static void
set_name_and_label (gfc_code *c, gfc_symbol *sym,
- char *name, char **binding_label)
+ char *name, const char **binding_label)
{
gfc_expr *arg = NULL;
char type;
@@ -3420,7 +3420,7 @@ gfc_iso_c_sub_interface (gfc_code *c, gfc_symbol *sym)
gfc_symbol *new_sym;
/* this is fine, since we know the names won't use the max */
char name[GFC_MAX_SYMBOL_LEN + 1];
- char* binding_label;
+ const char* binding_label;
/* default to success; will override if find error */
match m = MATCH_YES;
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index e13e1df..0cd7cc8 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -4683,7 +4683,7 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s,
gfc_symbol *
get_iso_c_sym (gfc_symbol *old_sym, char *new_name,
- char *new_binding_label, int add_optional_arg)
+ const char *new_binding_label, int add_optional_arg)
{
gfc_symtree *new_symtree = NULL;