From: Kaveh R. Ghazi Date: Fri, 20 Jun 2008 06:03:16 +0000 (+0000) Subject: arith.c (hollerith2representation): Fix for -Wc++-compat. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ece3f6639db4f74c38080858ff7629695635c284;p=gcc.git arith.c (hollerith2representation): Fix for -Wc++-compat. * arith.c (hollerith2representation): Fix for -Wc++-compat. * array.c (gfc_get_constructor): Likewise. * decl.c (gfc_get_data_variable, gfc_get_data_value, gfc_get_data, create_enum_history, gfc_match_final_decl): Likewise. * error.c (error_char): Likewise. * expr.c (gfc_get_expr, gfc_copy_expr): Likewise. * gfortran.h (gfc_get_charlen, gfc_get_array_spec, gfc_get_component, gfc_get_formal_arglist, gfc_get_actual_arglist, gfc_get_namelist, gfc_get_omp_clauses, gfc_get_interface, gfc_get_common_head, gfc_get_dt_list, gfc_get_array_ref, gfc_get_ref, gfc_get_equiv, gfc_get_case, gfc_get_iterator, gfc_get_alloc, gfc_get_wide_string): Likewise. * interface.c (count_types_test): Likewise. * intrinsic.c (add_char_conversions, gfc_intrinsic_init_1): Likewise. * io.c (gfc_match_open, gfc_match_close, match_filepos, match_io, gfc_match_inquire, gfc_match_wait): Likewise. * match.c (gfc_match, match_forall_iterator): Likewise. * module.c (gfc_get_pointer_info, gfc_get_use_rename, add_fixup, add_true_name, parse_string, write_atom, quote_string, mio_symtree_ref, mio_gmp_real, write_common_0): Likewise. * options.c (gfc_post_options): Likewise. * primary.c (match_integer_constant, match_hollerith_constant, match_boz_constant, match_real_constant, gfc_get_structure_ctor_component, gfc_match_structure_constructor): Likewise. * scanner.c (gfc_widechar_to_char, add_path_to_list, add_file_change, load_line, get_file, preprocessor_line, load_file, unescape_filename, gfc_read_orig_filename): Likewise. * simplify.c (gfc_simplify_ibits, gfc_simplify_ishft, gfc_simplify_ishftc): Likewise. * symbol.c (gfc_get_st_label, gfc_get_namespace, gfc_new_symtree, gfc_get_uop, gfc_new_symbol, save_symbol_data, gfc_get_gsymbol): Likewise. * target-memory.c (gfc_target_interpret_expr): Likewise. * trans-const.c (gfc_build_wide_string_const): Likewise. * trans-expr.c (gfc_add_interface_mapping): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_conversion, gfc_conv_intrinsic_int, gfc_conv_intrinsic_lib_function, gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate, gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax, gfc_conv_intrinsic_minmax_char, gfc_conv_intrinsic_ishftc, gfc_conv_intrinsic_index_scan_verify, gfc_conv_intrinsic_merge, gfc_conv_intrinsic_trim): Likewise. * trans.c (gfc_get_backend_locus): Likewise. * trans.h (gfc_get_ss): Likewise. From-SVN: r136982 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 63620393898..bc069651d5b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,51 @@ +2008-06-20 Kaveh R. Ghazi + + * arith.c (hollerith2representation): Fix for -Wc++-compat. + * array.c (gfc_get_constructor): Likewise. + * decl.c (gfc_get_data_variable, gfc_get_data_value, gfc_get_data, + create_enum_history, gfc_match_final_decl): Likewise. + * error.c (error_char): Likewise. + * expr.c (gfc_get_expr, gfc_copy_expr): Likewise. + * gfortran.h (gfc_get_charlen, gfc_get_array_spec, + gfc_get_component, gfc_get_formal_arglist, gfc_get_actual_arglist, + gfc_get_namelist, gfc_get_omp_clauses, gfc_get_interface, + gfc_get_common_head, gfc_get_dt_list, gfc_get_array_ref, + gfc_get_ref, gfc_get_equiv, gfc_get_case, gfc_get_iterator, + gfc_get_alloc, gfc_get_wide_string): Likewise. + * interface.c (count_types_test): Likewise. + * intrinsic.c (add_char_conversions, gfc_intrinsic_init_1): + Likewise. + * io.c (gfc_match_open, gfc_match_close, match_filepos, match_io, + gfc_match_inquire, gfc_match_wait): Likewise. + * match.c (gfc_match, match_forall_iterator): Likewise. + * module.c (gfc_get_pointer_info, gfc_get_use_rename, add_fixup, + add_true_name, parse_string, write_atom, quote_string, + mio_symtree_ref, mio_gmp_real, write_common_0): Likewise. + * options.c (gfc_post_options): Likewise. + * primary.c (match_integer_constant, match_hollerith_constant, + match_boz_constant, match_real_constant, + gfc_get_structure_ctor_component, gfc_match_structure_constructor): Likewise. + * scanner.c (gfc_widechar_to_char, add_path_to_list, + add_file_change, load_line, get_file, preprocessor_line, + load_file, unescape_filename, gfc_read_orig_filename): Likewise. + * simplify.c (gfc_simplify_ibits, gfc_simplify_ishft, + gfc_simplify_ishftc): Likewise. + * symbol.c (gfc_get_st_label, gfc_get_namespace, gfc_new_symtree, + gfc_get_uop, gfc_new_symbol, save_symbol_data, gfc_get_gsymbol): + Likewise. + * target-memory.c (gfc_target_interpret_expr): Likewise. + * trans-const.c (gfc_build_wide_string_const): Likewise. + * trans-expr.c (gfc_add_interface_mapping): Likewise. + * trans-intrinsic.c (gfc_conv_intrinsic_conversion, + gfc_conv_intrinsic_int, gfc_conv_intrinsic_lib_function, + gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_ctime, + gfc_conv_intrinsic_fdate, gfc_conv_intrinsic_ttynam, + gfc_conv_intrinsic_minmax, gfc_conv_intrinsic_minmax_char, + gfc_conv_intrinsic_ishftc, gfc_conv_intrinsic_index_scan_verify, + gfc_conv_intrinsic_merge, gfc_conv_intrinsic_trim): Likewise. + * trans.c (gfc_get_backend_locus): Likewise. + * trans.h (gfc_get_ss): Likewise. + 2008-06-18 Daniel Kraft PR fortran/36517, fortran/36492 diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index 8e6de3068f0..bd3214584dd 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -2413,7 +2413,7 @@ hollerith2representation (gfc_expr *result, gfc_expr *src) &src->where, gfc_typename(&result->ts)); } - result->representation.string = gfc_getmem (result_len + 1); + result->representation.string = XCNEWVEC (char, result_len + 1); memcpy (result->representation.string, src->representation.string, MIN (result_len, src_len)); diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index a34695e4241..c6bb5e857b9 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -678,7 +678,7 @@ gfc_get_constructor (void) { gfc_constructor *c; - c = gfc_getmem (sizeof(gfc_constructor)); + c = XCNEW (gfc_constructor); c->expr = NULL; c->iterator = NULL; c->next = NULL; diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 57db93fd8e1..869ece6c3f6 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -28,9 +28,9 @@ along with GCC; see the file COPYING3. If not see /* Macros to access allocate memory for gfc_data_variable, gfc_data_value and gfc_data. */ -#define gfc_get_data_variable() gfc_getmem (sizeof (gfc_data_variable)) -#define gfc_get_data_value() gfc_getmem (sizeof (gfc_data_value)) -#define gfc_get_data() gfc_getmem( sizeof (gfc_data)) +#define gfc_get_data_variable() XCNEW (gfc_data_variable) +#define gfc_get_data_value() XCNEW (gfc_data_value) +#define gfc_get_data() XCNEW (gfc_data) /* This flag is set if an old-style length selector is matched @@ -1140,7 +1140,7 @@ create_enum_history (gfc_symbol *sym, gfc_expr *init) enumerator_history *new_enum_history; gcc_assert (sym != NULL && init != NULL); - new_enum_history = gfc_getmem (sizeof (enumerator_history)); + new_enum_history = XCNEW (enumerator_history); new_enum_history->sym = sym; new_enum_history->initializer = init; @@ -6625,7 +6625,7 @@ gfc_match_final_decl (void) /* Add this symbol to the list of finalizers. */ gcc_assert (gfc_current_block ()->f2k_derived); ++sym->refs; - f = gfc_getmem (sizeof (gfc_finalizer)); + f = XCNEW (gfc_finalizer); f->procedure = sym; f->where = gfc_current_locus; f->next = gfc_current_block ()->f2k_derived->finalizers; diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index c34899f1337..4ef22d0cbc2 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -70,8 +70,8 @@ error_char (char c) { cur_error_buffer->allocated = cur_error_buffer->allocated ? cur_error_buffer->allocated * 2 : 1000; - cur_error_buffer->message = xrealloc (cur_error_buffer->message, - cur_error_buffer->allocated); + cur_error_buffer->message = XRESIZEVEC (char, cur_error_buffer->message, + cur_error_buffer->allocated); } cur_error_buffer->message[cur_error_buffer->index++] = c; } @@ -87,7 +87,7 @@ error_char (char c) if (index + 1 >= allocated) { allocated = allocated ? allocated * 2 : 1000; - line = xrealloc (line, allocated); + line = XRESIZEVEC (char, line, allocated); } line[index++] = c; if (c == '\n') diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index a8727430221..ace09de4347 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -33,7 +33,7 @@ gfc_get_expr (void) { gfc_expr *e; - e = gfc_getmem (sizeof (gfc_expr)); + e = XCNEW (gfc_expr); gfc_clear_ts (&e->ts); e->shape = NULL; e->ref = NULL; @@ -414,7 +414,7 @@ gfc_copy_expr (gfc_expr *p) /* Copy target representation, if it exists. */ if (p->representation.string) { - c = gfc_getmem (p->representation.length + 1); + c = XCNEWVEC (char, p->representation.length + 1); q->representation.string = c; memcpy (c, p->representation.string, (p->representation.length + 1)); } diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index ee60f9ae645..5d025db869b 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -792,7 +792,7 @@ typedef struct gfc_charlen } gfc_charlen; -#define gfc_get_charlen() gfc_getmem(sizeof(gfc_charlen)) +#define gfc_get_charlen() XCNEW (gfc_charlen) /* Type specification structure. FIXME: derived and cl could be union??? */ typedef struct @@ -824,7 +824,7 @@ typedef struct } gfc_array_spec; -#define gfc_get_array_spec() gfc_getmem(sizeof(gfc_array_spec)) +#define gfc_get_array_spec() XCNEW (gfc_array_spec) /* Components of derived types. */ @@ -844,7 +844,7 @@ typedef struct gfc_component } gfc_component; -#define gfc_get_component() gfc_getmem(sizeof(gfc_component)) +#define gfc_get_component() XCNEW (gfc_component) /* Formal argument lists are lists of symbols. */ typedef struct gfc_formal_arglist @@ -856,7 +856,7 @@ typedef struct gfc_formal_arglist } gfc_formal_arglist; -#define gfc_get_formal_arglist() gfc_getmem(sizeof(gfc_formal_arglist)) +#define gfc_get_formal_arglist() XCNEW (gfc_formal_arglist) /* The gfc_actual_arglist structure is for actual arguments. */ @@ -876,7 +876,7 @@ typedef struct gfc_actual_arglist } gfc_actual_arglist; -#define gfc_get_actual_arglist() gfc_getmem(sizeof(gfc_actual_arglist)) +#define gfc_get_actual_arglist() XCNEW (gfc_actual_arglist) /* Because a symbol can belong to multiple namelists, they must be @@ -888,7 +888,7 @@ typedef struct gfc_namelist } gfc_namelist; -#define gfc_get_namelist() gfc_getmem(sizeof(gfc_namelist)) +#define gfc_get_namelist() XCNEW (gfc_namelist) enum { @@ -945,7 +945,7 @@ typedef struct gfc_omp_clauses } gfc_omp_clauses; -#define gfc_get_omp_clauses() gfc_getmem(sizeof(gfc_omp_clauses)) +#define gfc_get_omp_clauses() XCNEW (gfc_omp_clauses) /* The gfc_st_label structure is a doubly linked list attached to a @@ -978,7 +978,7 @@ typedef struct gfc_interface } gfc_interface; -#define gfc_get_interface() gfc_getmem(sizeof(gfc_interface)) +#define gfc_get_interface() XCNEW (gfc_interface) /* User operator nodes. These are like stripped down symbols. */ @@ -1092,7 +1092,7 @@ typedef struct gfc_common_head } gfc_common_head; -#define gfc_get_common_head() gfc_getmem(sizeof(gfc_common_head)) +#define gfc_get_common_head() XCNEW (gfc_common_head) /* A list of all the alternate entry points for a procedure. */ @@ -1142,7 +1142,7 @@ typedef struct gfc_dt_list } gfc_dt_list; -#define gfc_get_dt_list() gfc_getmem(sizeof(gfc_dt_list)) +#define gfc_get_dt_list() XCNEW (gfc_dt_list) /* A list of all derived types. */ extern gfc_dt_list *gfc_derived_types; @@ -1277,7 +1277,7 @@ typedef struct gfc_array_ref } gfc_array_ref; -#define gfc_get_array_ref() gfc_getmem(sizeof(gfc_array_ref)) +#define gfc_get_array_ref() XCNEW (gfc_array_ref) /* Component reference nodes. A variable is stored as an expression @@ -1319,7 +1319,7 @@ typedef struct gfc_ref } gfc_ref; -#define gfc_get_ref() gfc_getmem(sizeof(gfc_ref)) +#define gfc_get_ref() XCNEW (gfc_ref) /* Structures representing intrinsic symbols and their arguments lists. */ @@ -1599,7 +1599,7 @@ typedef struct gfc_equiv } gfc_equiv; -#define gfc_get_equiv() gfc_getmem(sizeof(gfc_equiv)) +#define gfc_get_equiv() XCNEW (gfc_equiv) /* Holds a single equivalence member after processing. */ typedef struct gfc_equiv_info @@ -1651,7 +1651,7 @@ typedef struct gfc_case } gfc_case; -#define gfc_get_case() gfc_getmem(sizeof(gfc_case)) +#define gfc_get_case() XCNEW (gfc_case) typedef struct @@ -1660,7 +1660,7 @@ typedef struct } gfc_iterator; -#define gfc_get_iterator() gfc_getmem(sizeof(gfc_iterator)) +#define gfc_get_iterator() XCNEW (gfc_iterator) /* Allocation structure for ALLOCATE, DEALLOCATE and NULLIFY statements. */ @@ -1672,7 +1672,7 @@ typedef struct gfc_alloc } gfc_alloc; -#define gfc_get_alloc() gfc_getmem(sizeof(gfc_alloc)) +#define gfc_get_alloc() XCNEW (gfc_alloc) typedef struct @@ -1997,7 +1997,7 @@ gfc_char_t *gfc_wide_memset (gfc_char_t *, gfc_char_t, size_t); char *gfc_widechar_to_char (const gfc_char_t *, int); gfc_char_t *gfc_char_to_widechar (const char *); -#define gfc_get_wide_string(n) gfc_getmem((n) * sizeof(gfc_char_t)) +#define gfc_get_wide_string(n) XCNEWVEC (gfc_char_t, n) void gfc_skip_comments (void); gfc_char_t gfc_next_char_literal (int); diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f2ad4f6734e..724d662aaa8 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -795,7 +795,7 @@ count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2) /* Build an array of integers that gives the same integer to arguments of the same type/rank. */ - arg = gfc_getmem (n1 * sizeof (arginfo)); + arg = XCNEWVEC (arginfo, n1); f = f1; for (i = 0; i < n1; i++, f = f->next) diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index ebec5765ee5..df412757823 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -2853,7 +2853,7 @@ add_char_conversions (void) ncharconv++; /* Allocate memory. */ - char_conversions = gfc_getmem (sizeof (gfc_intrinsic_sym) * ncharconv); + char_conversions = XCNEWVEC (gfc_intrinsic_sym, ncharconv); /* Add the conversions themselves. */ n = 0; @@ -2905,13 +2905,14 @@ gfc_intrinsic_init_1 (void) sizing = SZ_CONVS; add_conversions (); - functions = gfc_getmem (sizeof (gfc_intrinsic_sym) * (nfunc + nsub) - + sizeof (gfc_intrinsic_arg) * nargs); + functions = XCNEWVAR (struct gfc_intrinsic_sym, + sizeof (gfc_intrinsic_sym) * (nfunc + nsub) + + sizeof (gfc_intrinsic_arg) * nargs); next_sym = functions; subroutines = functions + nfunc; - conversion = gfc_getmem (sizeof (gfc_intrinsic_sym) * nconv); + conversion = XCNEWVEC (gfc_intrinsic_sym, nconv); next_arg = ((gfc_intrinsic_arg *) (subroutines + nsub)) - 1; diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 9b417c21463..3494e8e863f 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1537,7 +1537,7 @@ gfc_match_open (void) if (m == MATCH_NO) return m; - open = gfc_getmem (sizeof (gfc_open)); + open = XCNEW (gfc_open); m = match_open_element (open); @@ -1927,7 +1927,7 @@ gfc_match_close (void) if (m == MATCH_NO) return m; - close = gfc_getmem (sizeof (gfc_close)); + close = XCNEW (gfc_close); m = match_close_element (close); @@ -2053,7 +2053,7 @@ match_filepos (gfc_statement st, gfc_exec_op op) gfc_filepos *fp; match m; - fp = gfc_getmem (sizeof (gfc_filepos)); + fp = XCNEW (gfc_filepos); if (gfc_match_char ('(') == MATCH_NO) { @@ -3218,7 +3218,7 @@ match_io (io_kind k) where = gfc_current_locus; comma_flag = 0; - current_dt = dt = gfc_getmem (sizeof (gfc_dt)); + current_dt = dt = XCNEW (gfc_dt); m = gfc_match_char ('('); if (m == MATCH_NO) { @@ -3569,7 +3569,7 @@ gfc_match_inquire (void) if (m == MATCH_NO) return m; - inquire = gfc_getmem (sizeof (gfc_inquire)); + inquire = XCNEW (gfc_inquire); loc = gfc_current_locus; @@ -3790,7 +3790,7 @@ gfc_match_wait (void) if (m == MATCH_NO) return m; - wait = gfc_getmem (sizeof (gfc_wait)); + wait = XCNEW (gfc_wait); loc = gfc_current_locus; diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d3f665f4440..6f5765f1784 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1222,7 +1222,7 @@ not_yes: case 'e': case 'v': vp = va_arg (argp, void **); - gfc_free_expr (*vp); + gfc_free_expr ((struct gfc_expr *)*vp); *vp = NULL; break; } @@ -3770,7 +3770,7 @@ match_forall_iterator (gfc_forall_iterator **result) match m; where = gfc_current_locus; - iter = gfc_getmem (sizeof (gfc_forall_iterator)); + iter = XCNEW (gfc_forall_iterator); m = gfc_match_expr (&iter->var); if (m != MATCH_YES) diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index f3c5316d05c..67b09c767e9 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -159,7 +159,7 @@ typedef struct pointer_info } pointer_info; -#define gfc_get_pointer_info() gfc_getmem(sizeof(pointer_info)) +#define gfc_get_pointer_info() XCNEW (pointer_info) /* Lists of rename info for the USE statement. */ @@ -174,7 +174,7 @@ typedef struct gfc_use_rename } gfc_use_rename; -#define gfc_get_use_rename() gfc_getmem(sizeof(gfc_use_rename)) +#define gfc_get_use_rename() XCNEW (gfc_use_rename); /* Local variables */ @@ -460,17 +460,17 @@ add_fixup (int integer, void *gp) if (p->integer == 0 || p->u.pointer != NULL) { - cp = gp; - *cp = p->u.pointer; + cp = (char **) gp; + *cp = (char *) p->u.pointer; } else { - f = gfc_getmem (sizeof (fixup_t)); + f = XCNEW (fixup_t); f->next = p->fixup; p->fixup = f; - f->pointer = gp; + f->pointer = (void **) gp; } return p; @@ -839,7 +839,7 @@ add_true_name (gfc_symbol *sym) { true_name *t; - t = gfc_getmem (sizeof (true_name)); + t = XCNEW (true_name); t->sym = sym; gfc_insert_bbt (&true_name_root, t, compare_true_names); @@ -1028,7 +1028,7 @@ parse_string (void) set_module_locus (&start); - atom_string = p = gfc_getmem (len + 1); + atom_string = p = XCNEWVEC (char, len + 1); for (; len > 0; len--) { @@ -1324,7 +1324,7 @@ write_atom (atom_type atom, const void *v) { case ATOM_STRING: case ATOM_NAME: - p = v; + p = (const char *) v; break; case ATOM_LPAREN: @@ -1496,7 +1496,7 @@ quote_string (const gfc_char_t *s, const size_t slength) len++; } - q = res = gfc_getmem (len + 1); + q = res = XCNEWVEC (char, len + 1); for (p = s, i = 0; i < slength; p++, i++) { if (*p == '\\') @@ -2455,7 +2455,7 @@ mio_symtree_ref (gfc_symtree **stp) } else { - f = gfc_getmem (sizeof (fixup_t)); + f = XCNEW (fixup_t); f->next = p->u.rsym.stfixup; p->u.rsym.stfixup = f; @@ -2674,7 +2674,7 @@ mio_gmp_real (mpfr_t *real) return; } - atom_string = gfc_getmem (strlen (p) + 20); + atom_string = XCNEWVEC (char, strlen (p) + 20); sprintf (atom_string, "0.%s@%ld", p, exponent); @@ -4126,7 +4126,7 @@ write_common_0 (gfc_symtree *st) mio_rparen (); /* Record that we have written this common. */ - w = gfc_getmem (sizeof (struct written_common)); + w = XCNEW (struct written_common); w->name = p->name; w->label = label; gfc_insert_bbt (&written_commons, w, compare_written_commons); diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index e653ac92843..8480364bc52 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -254,7 +254,7 @@ gfc_post_options (const char **pfilename) if (i != 0) { - source_path = alloca (i + 1); + source_path = (char *) alloca (i + 1); memcpy (source_path, canon_source_file, i); source_path[i] = 0; gfc_add_include_path (source_path, true); diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index a9b47d8bced..d7236e1be01 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -196,7 +196,7 @@ match_integer_constant (gfc_expr **result, int signflag) if (length == -1) return MATCH_NO; - buffer = alloca (length + 1); + buffer = (char *) alloca (length + 1); memset (buffer, '\0', length + 1); gfc_gobble_whitespace (); @@ -276,7 +276,7 @@ match_hollerith_constant (gfc_expr **result) e = gfc_constant_result (BT_HOLLERITH, gfc_default_character_kind, &gfc_current_locus); - e->representation.string = gfc_getmem (num + 1); + e->representation.string = XCNEWVEC (char, num + 1); for (i = 0; i < num; i++) { @@ -411,7 +411,7 @@ match_boz_constant (gfc_expr **result) gfc_current_locus = old_loc; - buffer = alloca (length + 1); + buffer = (char *) alloca (length + 1); memset (buffer, '\0', length + 1); match_digits (0, radix, buffer); @@ -562,7 +562,7 @@ done: gfc_current_locus = old_loc; gfc_gobble_whitespace (); - buffer = alloca (count + 1); + buffer = (char *) alloca (count + 1); memset (buffer, '\0', count + 1); p = buffer; @@ -1975,8 +1975,7 @@ typedef struct gfc_structure_ctor_component } gfc_structure_ctor_component; -#define gfc_get_structure_ctor_component() \ - gfc_getmem(sizeof(gfc_structure_ctor_component)) +#define gfc_get_structure_ctor_component() XCNEW (gfc_structure_ctor_component) static void gfc_free_structure_ctor_component (gfc_structure_ctor_component *comp) @@ -2023,7 +2022,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result) comp_tail->next = gfc_get_structure_ctor_component (); comp_tail = comp_tail->next; } - comp_tail->name = gfc_getmem(GFC_MAX_SYMBOL_LEN + 1); + comp_tail->name = XCNEWVEC (char, GFC_MAX_SYMBOL_LEN + 1); comp_tail->val = NULL; comp_tail->where = gfc_current_locus; diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 1b0eeca1e65..44e6d86bd4f 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -196,7 +196,7 @@ gfc_widechar_to_char (const gfc_char_t *s, int length) /* Passing a negative length is used to indicate that length should be calculated using gfc_wide_strlen(). */ len = (length >= 0 ? (size_t) length : gfc_wide_strlen (s)); - res = gfc_getmem (len + 1); + res = XNEWVEC (char, len + 1); for (i = 0; i < len; i++) { @@ -319,19 +319,19 @@ add_path_to_list (gfc_directorylist **list, const char *path, dir = *list; if (!dir) - dir = *list = gfc_getmem (sizeof (gfc_directorylist)); + dir = *list = XCNEW (gfc_directorylist); else { while (dir->next) dir = dir->next; - dir->next = gfc_getmem (sizeof (gfc_directorylist)); + dir->next = XCNEW (gfc_directorylist); dir = dir->next; } dir->next = NULL; dir->use_for_modules = use_for_modules; - dir->path = gfc_getmem (strlen (p) + 2); + dir->path = XCNEWVEC (char, strlen (p) + 2); strcpy (dir->path, p); strcat (dir->path, "/"); /* make '/' last character */ } @@ -495,9 +495,8 @@ add_file_change (const char *filename, int line) file_changes_allocated *= 2; else file_changes_allocated = 16; - file_changes - = xrealloc (file_changes, - file_changes_allocated * sizeof (*file_changes)); + file_changes = XRESIZEVEC (struct gfc_file_change, file_changes, + file_changes_allocated); } file_changes[file_changes_count].filename = filename; file_changes[file_changes_count].lb = NULL; @@ -1451,7 +1450,7 @@ load_line (FILE *input, gfc_char_t **pbuf, int *pbuflen, const int *first_char) /* Reallocate line buffer to double size to hold the overlong line. */ buflen = buflen * 2; - *pbuf = xrealloc (*pbuf, (buflen + 1) * sizeof (gfc_char_t)); + *pbuf = XRESIZEVEC (gfc_char_t, *pbuf, (buflen + 1)); buffer = (*pbuf) + i; } } @@ -1501,10 +1500,9 @@ get_file (const char *name, enum lc_reason reason ATTRIBUTE_UNUSED) { gfc_file *f; - f = gfc_getmem (sizeof (gfc_file)); + f = XCNEW (gfc_file); - f->filename = gfc_getmem (strlen (name) + 1); - strcpy (f->filename, name); + f->filename = xstrdup (name); f->next = file_head; file_head = f; @@ -1655,8 +1653,7 @@ preprocessor_line (gfc_char_t *c) if (strcmp (current_file->filename, filename) != 0) { gfc_free (current_file->filename); - current_file->filename = gfc_getmem (strlen (filename) + 1); - strcpy (current_file->filename, filename); + current_file->filename = xstrdup (filename); } /* Set new line number. */ @@ -1881,8 +1878,8 @@ load_file (const char *filename, bool initial) /* Add line. */ - b = gfc_getmem (gfc_linebuf_header_size - + (len + 1) * sizeof (gfc_char_t)); + b = (gfc_linebuf *) gfc_getmem (gfc_linebuf_header_size + + (len + 1) * sizeof (gfc_char_t)); b->location = linemap_line_start (line_table, current_file->line++, 120); @@ -1973,7 +1970,7 @@ unescape_filename (const char *ptr) /* Undo effects of cpp_quote_string. */ s = ptr; - d = gfc_getmem (p + 1 - ptr - unescape); + d = XCNEWVEC (char, p + 1 - ptr - unescape); ret = d; while (s != p) @@ -2046,7 +2043,7 @@ gfc_read_orig_filename (const char *filename, const char **canon_source_file) if (! IS_ABSOLUTE_PATH (filename)) { - char *p = gfc_getmem (len + strlen (filename)); + char *p = XCNEWVEC (char, len + strlen (filename)); memcpy (p, dirname, len - 2); p[len - 2] = '/'; diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 058a9f293a1..c889dae14fa 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -1595,7 +1595,7 @@ gfc_simplify_ibits (gfc_expr *x, gfc_expr *y, gfc_expr *z) convert_mpz_to_unsigned (result->value.integer, gfc_integer_kinds[k].bit_size); - bits = gfc_getmem (bitsize * sizeof (int)); + bits = XCNEWVEC (int, bitsize); for (i = 0; i < bitsize; i++) bits[i] = 0; @@ -2030,7 +2030,7 @@ gfc_simplify_ishft (gfc_expr *e, gfc_expr *s) return range_check (result, "ISHFT"); } - bits = gfc_getmem (isize * sizeof (int)); + bits = XCNEWVEC (int, isize); for (i = 0; i < isize; i++) bits[i] = mpz_tstbit (e->value.integer, i); @@ -2134,7 +2134,7 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gfc_expr *sz) convert_mpz_to_unsigned (result->value.integer, isize); - bits = gfc_getmem (ssize * sizeof (int)); + bits = XCNEWVEC (int, ssize); for (i = 0; i < ssize; i++) bits[i] = mpz_tstbit (e->value.integer, i); diff --git a/gcc/fortran/st.c b/gcc/fortran/st.c index abe7b94865c..ba5656b24d5 100644 --- a/gcc/fortran/st.c +++ b/gcc/fortran/st.c @@ -48,7 +48,7 @@ gfc_get_code (void) { gfc_code *c; - c = gfc_getmem (sizeof (gfc_code)); + c = XCNEW (gfc_code); c->loc = gfc_current_locus; return c; } diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index e4e43244d59..cd181d4f0f1 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1950,7 +1950,7 @@ gfc_get_st_label (int labelno) lp = lp->right; } - lp = gfc_getmem (sizeof (gfc_st_label)); + lp = XCNEW (gfc_st_label); lp->value = labelno; lp->defined = ST_LABEL_UNKNOWN; @@ -2116,7 +2116,7 @@ gfc_get_namespace (gfc_namespace *parent, int parent_types) gfc_intrinsic_op in; int i; - ns = gfc_getmem (sizeof (gfc_namespace)); + ns = XCNEW (gfc_namespace); ns->sym_root = NULL; ns->uop_root = NULL; ns->finalizers = NULL; @@ -2184,7 +2184,7 @@ gfc_new_symtree (gfc_symtree **root, const char *name) { gfc_symtree *st; - st = gfc_getmem (sizeof (gfc_symtree)); + st = XCNEW (gfc_symtree); st->name = gfc_get_string (name); gfc_insert_bbt (root, st, compare_symtree); @@ -2259,7 +2259,7 @@ gfc_get_uop (const char *name) st = gfc_new_symtree (&gfc_current_ns->uop_root, name); - uop = st->n.uop = gfc_getmem (sizeof (gfc_user_op)); + uop = st->n.uop = XCNEW (gfc_user_op); uop->name = gfc_get_string (name); uop->access = ACCESS_UNKNOWN; uop->ns = gfc_current_ns; @@ -2321,7 +2321,7 @@ gfc_new_symbol (const char *name, gfc_namespace *ns) { gfc_symbol *p; - p = gfc_getmem (sizeof (gfc_symbol)); + p = XCNEW (gfc_symbol); gfc_clear_ts (&p->ts); gfc_clear_attr (&p->attr); @@ -2434,7 +2434,7 @@ save_symbol_data (gfc_symbol *sym) if (sym->new || sym->old_symbol != NULL) return; - sym->old_symbol = gfc_getmem (sizeof (gfc_symbol)); + sym->old_symbol = XCNEW (gfc_symbol); *(sym->old_symbol) = *sym; sym->tlink = changed_syms; @@ -3197,7 +3197,7 @@ gfc_get_gsymbol (const char *name) if (s != NULL) return s; - s = gfc_getmem (sizeof (gfc_gsymbol)); + s = XCNEW (gfc_gsymbol); s->type = GSYM_UNKNOWN; s->name = gfc_get_string (name); diff --git a/gcc/fortran/target-memory.c b/gcc/fortran/target-memory.c index e1f9b7c33a4..40e595ba404 100644 --- a/gcc/fortran/target-memory.c +++ b/gcc/fortran/target-memory.c @@ -527,7 +527,7 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t buffer_size, else { result->representation.string = - gfc_getmem (result->representation.length + 1); + (char *) gfc_getmem (result->representation.length + 1); memcpy (result->representation.string, buffer, result->representation.length); result->representation.string[result->representation.length] = '\0'; diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c index e4da3f08647..fd3d58f56b3 100644 --- a/gcc/fortran/trans-const.c +++ b/gcc/fortran/trans-const.c @@ -99,7 +99,7 @@ gfc_build_wide_string_const (int kind, int length, const gfc_char_t *string) i = gfc_validate_kind (BT_CHARACTER, kind, false); size = length * gfc_character_kinds[i].bit_size / 8; - s = gfc_getmem (size); + s = XCNEWVAR (char, size); gfc_encode_character (kind, length, string, (unsigned char *) s, size); str = build_string (size, s); diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index cfd33e464bc..59a0a2d8eb7 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1593,7 +1593,7 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, gcc_assert (new_symtree == root); /* Create a dummy->actual mapping. */ - sm = gfc_getmem (sizeof (*sm)); + sm = XCNEW (gfc_interface_sym_mapping); sm->next = mapping->syms; sm->old = sym; sm->new = new_symtree; diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index c032675cfcb..31780240cd2 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -241,7 +241,7 @@ gfc_conv_intrinsic_conversion (gfc_se * se, gfc_expr * expr) int nargs; nargs = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * nargs); + args = (tree *) alloca (sizeof (tree) * nargs); /* Evaluate all the arguments passed. Whilst we're only interested in the first one here, there are other parts of the front-end that assume this @@ -514,7 +514,7 @@ gfc_conv_intrinsic_int (gfc_se * se, gfc_expr * expr, enum rounding_mode op) int nargs; nargs = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * nargs); + args = (tree *) alloca (sizeof (tree) * nargs); /* Evaluate the argument, we process all arguments even though we only use the first one for code generation purposes. */ @@ -736,7 +736,7 @@ gfc_conv_intrinsic_lib_function (gfc_se * se, gfc_expr * expr) /* Get the decl and generate the call. */ num_args = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); gfc_conv_intrinsic_function_args (se, expr, args, num_args); fndecl = gfc_get_intrinsic_lib_fndecl (m, expr); @@ -1037,7 +1037,7 @@ gfc_conv_intrinsic_cmplx (gfc_se * se, gfc_expr * expr, int both) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); type = gfc_typenode_for_spec (&expr->ts); gfc_conv_intrinsic_function_args (se, expr, args, num_args); @@ -1333,7 +1333,7 @@ gfc_conv_intrinsic_ctime (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr) + 2; - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); var = gfc_create_var (pchar_type_node, "pstr"); len = gfc_create_var (gfc_get_int_type (8), "len"); @@ -1371,7 +1371,7 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr) + 2; - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); var = gfc_create_var (pchar_type_node, "pstr"); len = gfc_create_var (gfc_get_int_type (4), "len"); @@ -1411,7 +1411,7 @@ gfc_conv_intrinsic_ttynam (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr) + 2; - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); var = gfc_create_var (pchar_type_node, "pstr"); len = gfc_create_var (gfc_get_int_type (4), "len"); @@ -1465,7 +1465,7 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, int op) unsigned int i, nargs; nargs = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * nargs); + args = (tree *) alloca (sizeof (tree) * nargs); gfc_conv_intrinsic_function_args (se, expr, args, nargs); type = gfc_typenode_for_spec (&expr->ts); @@ -1536,7 +1536,7 @@ gfc_conv_intrinsic_minmax_char (gfc_se * se, gfc_expr * expr, int op) unsigned int nargs; nargs = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * (nargs + 4)); + args = (tree *) alloca (sizeof (tree) * (nargs + 4)); gfc_conv_intrinsic_function_args (se, expr, &args[4], nargs); /* Create the result variables. */ @@ -2586,7 +2586,7 @@ gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); gfc_conv_intrinsic_function_args (se, expr, args, num_args); @@ -2751,7 +2751,7 @@ gfc_conv_intrinsic_index_scan_verify (gfc_se * se, gfc_expr * expr, tree *args; unsigned int num_args; - args = alloca (sizeof (tree) * 5); + args = (tree *) alloca (sizeof (tree) * 5); /* Get number of arguments; characters count double due to the string length argument. Kind= is not passed to the libary @@ -2836,7 +2836,7 @@ gfc_conv_intrinsic_merge (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr); - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); gfc_conv_intrinsic_function_args (se, expr, args, num_args); if (expr->ts.type != BT_CHARACTER) @@ -3894,7 +3894,7 @@ gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr) unsigned int num_args; num_args = gfc_intrinsic_argument_list_length (expr) + 2; - args = alloca (sizeof (tree) * num_args); + args = (tree *) alloca (sizeof (tree) * num_args); var = gfc_create_var (gfc_get_pchar_type (expr->ts.kind), "pstr"); addr = gfc_build_addr_expr (ppvoid_type_node, var); diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 51e0cdd6aad..5bd3005a2b3 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -933,7 +933,7 @@ gfc_add_block_to_block (stmtblock_t * block, stmtblock_t * append) void gfc_get_backend_locus (locus * loc) { - loc->lb = gfc_getmem (sizeof (gfc_linebuf)); + loc->lb = XCNEW (gfc_linebuf); loc->lb->location = input_location; loc->lb->file = gfc_current_backend_file; } diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h index 3a07d712791..81c449e91a5 100644 --- a/gcc/fortran/trans.h +++ b/gcc/fortran/trans.h @@ -206,7 +206,7 @@ typedef struct gfc_ss unsigned useflags:2, where:1; } gfc_ss; -#define gfc_get_ss() gfc_getmem(sizeof(gfc_ss)) +#define gfc_get_ss() XCNEW (gfc_ss) /* The contents of this aren't actually used. A NULL SS chain indicates a scalar expression, so this pointer is used to terminate SS chains. */