->find_slot_with_hash (&str, substring_hash (str.str, str.length),
INSERT);
gcc_assert (!*slot || attr->name[0] == '*');
- *slot = CONST_CAST (struct attribute_spec *, attr);
+ *slot = const_cast<struct attribute_spec *> (attr);
}
/* Return the spec for the scoped attribute with namespace NS and
&& CONST_INT_P (len_rtx)
&& (unsigned HOST_WIDE_INT) INTVAL (len_rtx) <= nbytes
&& can_store_by_pieces (INTVAL (len_rtx), builtin_memcpy_read_str,
- CONST_CAST (char *, rep),
+ const_cast<char *> (rep),
dest_align, false))
{
dest_mem = store_by_pieces (dest_mem, INTVAL (len_rtx),
builtin_memcpy_read_str,
- CONST_CAST (char *, rep),
+ const_cast<char *> (rep),
dest_align, false, retmode);
dest_mem = force_operand (XEXP (dest_mem, 0), target);
dest_mem = convert_memory_address (ptr_mode, dest_mem);
if (!p || dest_align == 0 || !tree_fits_uhwi_p (len)
|| !can_store_by_pieces (tree_to_uhwi (len),
builtin_strncpy_read_str,
- CONST_CAST (char *, p),
+ const_cast<char *> (p),
dest_align, false))
return NULL_RTX;
dest_mem = get_memory_rtx (dest, len);
store_by_pieces (dest_mem, tree_to_uhwi (len),
builtin_strncpy_read_str,
- CONST_CAST (char *, p), dest_align, false,
+ const_cast<char *> (p), dest_align, false,
RETURN_BEGIN);
dest_mem = force_operand (XEXP (dest_mem, 0), target);
dest_mem = convert_memory_address (ptr_mode, dest_mem);
result = emit_block_cmp_hints (arg1_rtx, arg2_rtx, len_rtx,
TREE_TYPE (len), target,
result_eq, constfn,
- CONST_CAST (char *, rep),
+ const_cast<char *> (rep),
tree_ctz (len));
if (result)
{
error ("size of string literal is too large");
length = tree_to_shwi (TYPE_MAX_VALUE (ssizetype)) / charsz * charsz;
- char *str = CONST_CAST (char *, TREE_STRING_POINTER (value));
+ char *str = const_cast<char *> (TREE_STRING_POINTER (value));
memset (str + length, '\0',
MIN (TREE_STRING_LENGTH (value) - length, charsz));
TREE_STRING_LENGTH (value) = length;
if (cpp_interpret_string (pfile, str, 1, &cstr, CPP_STRING))
{
targetm.asm_out.output_ident ((const char *) cstr.text);
- free (CONST_CAST (unsigned char *, cstr.text));
+ free (const_cast<unsigned char *> (cstr.text));
}
}
}
(const char *) tok->val.str.text);
TREE_TYPE (num_string) = char_array_type_node;
num_string = fix_string_type (num_string);
- str = CONST_CAST (char *, TREE_STRING_POINTER (num_string));
+ str = const_cast<char *> (TREE_STRING_POINTER (num_string));
str[len] = '\0';
literal = build_userdef_literal (suffix_id, *value, overflow,
num_string);
(parse_in, strs, concats + 1, &istr, type))
{
value = build_string (istr.len, (const char *) istr.text);
- free (CONST_CAST (unsigned char *, istr.text));
+ free (const_cast<unsigned char *> (istr.text));
if (concats)
{
gcc_assert (locs);
DECL_ARTIFICIAL (decl) = 1;
init = build_string (length + 1, name);
- free (CONST_CAST (char *, name));
+ free (const_cast<char *> (name));
TREE_TYPE (init) = type;
DECL_INITIAL (decl) = init;
(parse_in, strs, count, &istr, type)))
{
value = build_string (istr.len, (const char *) istr.text);
- free (CONST_CAST (unsigned char *, istr.text));
+ free (const_cast<unsigned char *> (istr.text));
if (count > 1)
{
location_t *locs = (location_t *) obstack_finish (&loc_ob);
non-const char * filename parameter, even though it will not
modify that string. So we must cast away const-ness here,
using CONST_CAST to prevent complaints from -Wcast-qual. */
- if ((ldptr = ldopen (CONST_CAST (char *, prog_name), ldptr)) != NULL)
+ if ((ldptr = ldopen (const_cast<char *> (prog_name), ldptr)) != NULL)
{
if (! MY_ISCOFF (HEADER (ldptr).f_magic))
{
for (int i = 0; i < nr_accessors; i++)
n += snprintf (str + n, sizeof (str) - n,
i == 0 ? "%u" : ":%u", accessors[i]);
- ret.str = CONST_CAST (char *, ggc_strdup (str));
+ ret.str = const_cast<char *> (ggc_strdup (str));
}
else
gcc_unreachable ();
in 6 chars. */
char tmp[6];
sprintf (tmp, "%u", index);
- ret.str = CONST_CAST (char *, ggc_strdup(tmp));
+ ret.str = const_cast<char *> (ggc_strdup (tmp));
return ret;
}
{
if (verbose)
fprintf (stderr, "%s\n", string);
- putenv (CONST_CAST (char *, string));
+ putenv (const_cast<char *> (string));
}
/* Parse STR, saving found tokens into PVALUES and return their number.
obstack_ptr_grow (&argv_obstack, NULL);
const char **new_argv = XOBFINISH (&argv_obstack, const char **);
- fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+ fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
".gccnative_args");
obstack_free (&argv_obstack, NULL);
}
obstack_ptr_grow (&files_to_cleanup, omp_requires_file);
/* Run the compiler pass. */
- xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
- fork_execute (cc_argv[0], CONST_CAST (char **, cc_argv), true, ".gcc_args");
+ xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file,
+ NULL));
+ fork_execute (cc_argv[0], const_cast<char **> (cc_argv), true,
+ ".gcc_args");
obstack_free (&cc_argv_obstack, NULL);
unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
fclose (out);
/* Run the assemble/link pass. */
- fork_execute (ld_argv[0], CONST_CAST (char **, ld_argv), true, ".ld_args");
+ fork_execute (ld_argv[0], const_cast<char **> (ld_argv), true,
+ ".ld_args");
obstack_free (&ld_argv_obstack, NULL);
process_obj (gcn_o_name, cfile, omp_requires);
{
if (verbose)
fprintf (stderr, "%s\n", string);
- putenv (CONST_CAST (char *, string));
+ putenv (const_cast<char *> (string));
}
obstack_ptr_grow (&argv_obstack, NULL);
const char **new_argv = XOBFINISH (&argv_obstack, const char **);
- fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+ fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
".gccnative_args");
obstack_free (&argv_obstack, NULL);
}
omp_requires_file = make_temp_file (".mkoffload.omp_requires");
xputenv (concat ("GCC_OFFLOAD_OMP_REQUIRES_FILE=", omp_requires_file, NULL));
- fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+ fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
".gcc_args");
obstack_free (&argv_obstack, NULL);
unsetenv("GCC_OFFLOAD_OMP_REQUIRES_FILE");
static const char *
section_for_decl (const_tree decl)
{
- return section_for_sym (XEXP (DECL_RTL (CONST_CAST (tree, decl)), 0));
+ return section_for_sym (XEXP (DECL_RTL (const_cast<tree> (decl)), 0));
}
/* Check NAME for special function names and redirect them by returning a
else
pretty_name = identifier_to_locale (IDENTIFIER_POINTER (name));
- return CONST_CAST (char *, pretty_name);
+ return const_cast<char *> (pretty_name);
}
/* If CANDIDATES contains exactly one candidate, return it, otherwise
(parse_in, strs, count, &istr, type))
{
value = build_string (istr.len, (const char *)istr.text);
- free (CONST_CAST (unsigned char *, istr.text));
+ free (const_cast<unsigned char *> (istr.text));
if (count > 1)
{
location_t *locs = (location_t *)obstack_finish (&loc_ob);
not add null strings, return the offset to the empty string for them. */
if ((!name || (name != NULL && !strcmp (name, ""))) && str_offset)
{
- ctf_string = CONST_CAST (char *, str_table->ctstab_estr);
+ ctf_string = const_cast<char *> (str_table->ctstab_estr);
str_offset = 0;
}
else
gcc_assert (name);
/* Add null-terminated strings to the string table. */
len = strlen (name) + 1;
- ctf_string = CONST_CAST (char *, ggc_strdup (name));
+ ctf_string = const_cast<char *> (ggc_strdup (name));
ctfc_strtable_append_str (str_table, ctf_string);
/* Add string to the string table. Keep number of strings updated. */
}
else
/* Filename is an absolute path. */
- cuname = CONST_CAST (char *, ggc_strdup (filename));
+ cuname = const_cast<char *> (ggc_strdup (filename));
ctf_add_string (ctfc, cuname, &(ctfc->ctfc_cuname_offset));
/* Add 1 as CTF strings in the CTF string table are null-terminated
{
const void *string = TREE_STRING_POINTER (cst);
size_t len = TREE_STRING_LENGTH (cst) - 1;
- return StringExp::create (loc, CONST_CAST (void *, string), len);
+ return StringExp::create (loc, const_cast<void *> (string), len);
}
else if (code == VECTOR_CST)
{
if (target == NULL || !FileName::exists (target))
{
if (target)
- free (CONST_CAST (char *, target));
+ free (const_cast<char *> (target));
continue;
}
if (!FileName::exists (target))
{
- free (CONST_CAST (char *, target));
+ free (const_cast<char *> (target));
continue;
}
break;
case OPT_fdebug_:
- if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
+ if (Identifier::isValidIdentifier (const_cast<char *> (arg)))
{
DebugCondition::addGlobalIdent (arg);
break;
break;
case OPT_fversion_:
- if (Identifier::isValidIdentifier (CONST_CAST (char *, arg)))
+ if (Identifier::isValidIdentifier (const_cast<char *> (arg)))
{
VersionCondition::addGlobalIdent (arg);
break;
break;
case OPT_defaultlib_:
- free (CONST_CAST (char *, defaultlib));
+ free (const_cast<char *> (defaultlib));
if (arg != NULL)
{
args[i] |= SKIPOPT;
break;
case OPT_debuglib_:
- free (CONST_CAST (char *, debuglib));
+ free (const_cast<char *> (debuglib));
if (arg != NULL)
{
args[i] |= SKIPOPT;
unsigned identlen = IDENTIFIER_LENGTH (target_name) + 14;
ident = XNEWVEC (const char, identlen);
- snprintf (CONST_CAST (char *, ident), identlen,
+ snprintf (const_cast<char *> (ident), identlen,
"_DTi%u%s", offset, IDENTIFIER_POINTER (target_name));
}
d_keep (thunk);
if (decl->resolvedLinkage () != LINK::cpp)
- free (CONST_CAST (char *, ident));
+ free (const_cast<char *> (ident));
/* Thunks are connected to the definitions of the functions, so thunks are
not produced for external functions. */
dump_files[i].pstate = 1;
}
if (old_filename && filename != old_filename)
- free (CONST_CAST (char *, old_filename));
+ free (const_cast<char *> (old_filename));
}
}
m_extra_dump_files[i].pstate = 1;
}
if (old_filename && filename != old_filename)
- free (CONST_CAST (char *, old_filename));
+ free (const_cast<char *> (old_filename));
}
}
if (m_optinfo_filename)
dfi->alt_filename = xstrdup (m_optinfo_filename);
if (old_filename && m_optinfo_filename != old_filename)
- free (CONST_CAST (char *, old_filename));
+ free (const_cast<char *> (old_filename));
return true;
}
if (filename)
{
if (dfi->pfilename)
- free (CONST_CAST (char *, dfi->pfilename));
+ free (const_cast<char *> (dfi->pfilename));
dfi->pfilename = xstrdup (filename);
}
/* {auto,}vec.safe_push () replacement. Don't ask.. */
// if (strlen (elt) < 4) return; premature optimization: eliminated by cutoff
optr = XRESIZEVEC (char *, optr, osz + 2);
- optr[osz] = CONST_CAST (char *, elt);
+ optr[osz] =
+#ifdef __cplusplus
+ const_cast<char *> (elt);
+#else
+ (__extension__ (union {const char *_q; const char *_nq;})(elt))._nq;
+#endif
optr[++osz] = NULL;
}
break;
case EXPR_SUBSTRING:
- e->value.character.string
- = CONST_CAST (gfc_char_t *,
- mio_allocated_wide_string (e->value.character.string,
- e->value.character.length));
+ e->value.character.string = const_cast<gfc_char_t *>
+ (mio_allocated_wide_string (e->value.character.string,
+ e->value.character.length));
mio_ref_list (&e->ref);
break;
hwi = e->value.character.length;
mio_hwi (&hwi);
e->value.character.length = hwi;
- e->value.character.string
- = CONST_CAST (gfc_char_t *,
- mio_allocated_wide_string (e->value.character.string,
- e->value.character.length));
+ e->value.character.string = const_cast<gfc_char_t *>
+ (mio_allocated_wide_string (e->value.character.string,
+ e->value.character.length));
break;
default:
gfc_free_expr_list (c->wait_list);
gfc_free_expr_list (c->tile_list);
gfc_free_expr_list (c->sizes_list);
- free (CONST_CAST (char *, c->critical_name));
+ free (const_cast<char *> (c->critical_name));
if (c->assume)
{
free (c->assume->absent);
gfc_add_include_path (".", true, true, false, false);
if (canon_source_file != gfc_source_file)
- free (CONST_CAST (char *, canon_source_file));
+ free (const_cast<char *> (canon_source_file));
/* Decide which form the file will be read in as. */
new_st.ext.omp_name) != 0))
gfc_error ("Name after !$omp critical and !$omp end critical does "
"not match at %C");
- free (CONST_CAST (char *, new_st.ext.omp_name));
+ free (const_cast<char *> (new_st.ext.omp_name));
new_st.ext.omp_name = NULL;
break;
case EXEC_OMP_END_SINGLE:
{
do {
if (*s == c)
- {
- return CONST_CAST(gfc_char_t *, s);
- }
+ return const_cast<gfc_char_t *> (s);
} while (*s++);
return 0;
}
break;
case EXEC_OMP_END_CRITICAL:
- free (CONST_CAST (char *, p->ext.omp_name));
+ free (const_cast<char *> (p->ext.omp_name));
break;
case EXEC_OMP_FLUSH:
for (hash_map<nofree_string_hash, int>::iterator it
= gfc_vectorized_builtins->begin ();
it != gfc_vectorized_builtins->end (); ++it)
- free (CONST_CAST (char *, (*it).first));
+ free (const_cast<char *> ((*it).first));
delete gfc_vectorized_builtins;
gfc_vectorized_builtins = NULL;
m_keys.safe_push (kv);
}
- ::putenv (CONST_CAST (char *, string));
+ ::putenv (const_cast<char *> (string));
}
/* Undo any xputenv changes made since last restore.
/* Free the old spec. */
if (old_spec && sl->alloc_p)
- free (CONST_CAST (char *, old_spec));
+ free (const_cast<char *> (old_spec));
sl->user_p = user_p;
sl->alloc_p = true;
/* Copy the strings over. */
for (i = 0; i < n_args; i++)
- argv[i] = CONST_CAST (char *, at_file_argbuf[i]);
+ argv[i] = const_cast<char *> (at_file_argbuf[i]);
argv[i] = NULL;
at_file_argbuf.truncate (0);
set_spec (p2, *(sl->ptr_spec), user_p);
if (sl->alloc_p)
- free (CONST_CAST (char *, *(sl->ptr_spec)));
+ free (const_cast<char *> (*(sl->ptr_spec)));
*(sl->ptr_spec) = "";
sl->alloc_p = 0;
Don't repeat any we have already seen. */
if (multi_dir)
{
- free (CONST_CAST (char *, multi_dir));
+ free (const_cast<char *> (multi_dir));
multi_dir = NULL;
- free (CONST_CAST (char *, multi_suffix));
+ free (const_cast<char *> (multi_suffix));
multi_suffix = machine_suffix;
- free (CONST_CAST (char *, just_multi_suffix));
+ free (const_cast<char *> (just_multi_suffix));
just_multi_suffix = just_machine_suffix;
}
else
skip_multi_dir = true;
if (multi_os_dir)
{
- free (CONST_CAST (char *, multi_os_dir));
+ free (const_cast<char *> (multi_os_dir));
multi_os_dir = NULL;
}
else
if (multi_dir)
{
- free (CONST_CAST (char *, multi_dir));
- free (CONST_CAST (char *, multi_suffix));
- free (CONST_CAST (char *, just_multi_suffix));
+ free (const_cast<char *> (multi_dir));
+ free (const_cast<char *> (multi_suffix));
+ free (const_cast<char *> (just_multi_suffix));
}
if (multi_os_dir)
- free (CONST_CAST (char *, multi_os_dir));
+ free (const_cast<char *> (multi_os_dir));
if (ret != path)
free (path);
return ret;
errmsg = pex_run (pex,
((i + 1 == n_commands ? PEX_LAST : 0)
| (string == commands[i].prog ? PEX_SEARCH : 0)),
- string, CONST_CAST (char **, commands[i].argv),
+ string, const_cast<char **> (commands[i].argv),
NULL, NULL, &err);
if (errmsg != NULL)
{
}
if (i && string != commands[i].prog)
- free (CONST_CAST (char *, string));
+ free (const_cast<char *> (string));
}
execution_count++;
}
if (commands[0].argv[0] != commands[0].prog)
- free (CONST_CAST (char *, commands[0].argv[0]));
+ free (const_cast<char *> (commands[0].argv[0]));
return ret_code;
}
while (length-- && !IS_DIR_SEPARATOR (arg[length]))
if (arg[length] == '.')
{
- (CONST_CAST (char *, arg))[length] = 0;
+ (const_cast<char *> (arg))[length] = 0;
dot = 1;
break;
}
do_spec_1 (arg, 1, NULL);
if (dot)
- (CONST_CAST (char *, arg))[length] = '.';
+ (const_cast<char *> (arg))[length] = '.';
do_spec_1 (suffix_subst, 1, NULL);
}
else
if (multilib_dir == NULL && multilib_os_dir != NULL
&& strcmp (multilib_os_dir, ".") == 0)
{
- free (CONST_CAST (char *, multilib_os_dir));
+ free (const_cast<char *> (multilib_os_dir));
multilib_os_dir = NULL;
}
else if (multilib_dir != NULL && multilib_os_dir == NULL)
}
/* Remove the extension. */
- cptr = strrchr (CONST_CAST (char *, lbasename (name)), '.');
+ cptr = strrchr (const_cast<char *> (lbasename (name)), '.');
if (cptr)
*cptr = 0;
l1 = strlen (s1);
l2 = strlen (s2);
- buf = XRESIZEVEC (char, CONST_CAST (char *, s1), l1 + l2 + 1);
+ buf = XRESIZEVEC (char, const_cast<char *> (s1), l1 + l2 + 1);
memcpy (buf + l1, s2, l2 + 1);
- XDELETE (CONST_CAST (char *, s2));
+ XDELETE (const_cast<char *> (s2));
s1 = buf;
}
return s1;
case TYPE_LANG_STRUCT:
case TYPE_USER_STRUCT:
case TYPE_UNDEFINED:
- return CONST_CAST (struct fileloc*, &ty->u.s.line);
+ return const_cast<struct fileloc*> (&ty->u.s.line);
case TYPE_SCALAR:
case TYPE_STRING:
case TYPE_POINTER:
static outf_p
source_dot_cc_frul (input_file* inpf, char**poutname, char**pforname)
{
- char *newbasename = CONST_CAST (char*, get_file_basename (inpf));
- char *newoutname = CONST_CAST (char*, get_file_gtfilename (inpf));
+ char *newbasename = const_cast<char*> (get_file_basename (inpf));
+ char *newoutname = const_cast<char*> (get_file_gtfilename (inpf));
DBGPRINTF ("inpf %p inpname %s original outname %s forname %s",
(void*) inpf, get_input_file_name (inpf),
*poutname, *pforname);
oprintf (of, "%lu%s", (unsigned long) strlen (id_for_tag),
id_for_tag);
if (id_for_tag != t->u.s.tag)
- free (CONST_CAST (char *, id_for_tag));
+ free (const_cast<char *> (id_for_tag));
}
break;
case TYPE_ARRAY:
/* The call to get_output_file_with_visibility may update fn by
caching its result inside, so we need the CONST_CAST. */
- return get_output_file_with_visibility (CONST_CAST (input_file*, fn));
+ return get_output_file_with_visibility (const_cast<input_file*> (fn));
}
const char *id_for_tag = filter_type_name (s->u.s.tag);
oprintf (of, "gt_%sx_%s", prefix, id_for_tag);
if (id_for_tag != s->u.s.tag)
- free (CONST_CAST (char *, id_for_tag));
+ free (const_cast<char *> (id_for_tag));
}
else
gcc_unreachable ();
"#define gt_%sx_%s gt_%sx_%s\n",
wtd->prefix, s->u.s.tag, wtd->prefix, t_id_for_tag);
if (t_id_for_tag != t->u.s.tag)
- free (CONST_CAST (char *, t_id_for_tag));
+ free (const_cast<char *> (t_id_for_tag));
}
else
error_at_line (&s->u.s.line,
wtd->prefix, s_id_for_tag);
if (s_id_for_tag != s->u.s.tag)
- free (CONST_CAST (char *, s_id_for_tag));
+ free (const_cast<char *> (s_id_for_tag));
if (s->u.s.line.file == NULL)
{
/* The call to get_output_file_name may indirectly update fn since
get_output_file_with_visibility caches its result inside, so we
need the CONST_CAST. */
- const char *name = get_output_file_name (CONST_CAST (input_file*, inpf));
+ const char *name = get_output_file_name (const_cast<input_file*> (inpf));
if (!f || !name)
return;
for (; *name != 0; name++)
else
oprintf (f, " NULL");
if (id_for_tag != tp->u.s.tag)
- free (CONST_CAST (char *, id_for_tag));
+ free (const_cast<char *> (id_for_tag));
}
else if (has_length
&& (tp->kind == TYPE_POINTER || union_or_struct_p (tp)))
for (v = variables; v; v = v->next)
{
outf_p f =
- get_output_file_with_visibility (CONST_CAST (input_file*,
+ get_output_file_with_visibility (const_cast<input_file*> (
v->line.file));
struct flist *fli;
const char *length = NULL;
for (v = variables; v; v = v->next)
{
- outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+ outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
v->line.file));
struct flist *fli;
int skip_p = 0;
for (v = variables; v; v = v->next)
{
- outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+ outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
v->line.file));
struct flist *fli;
int skip_p = 1;
for (v = variables; v; v = v->next)
{
- outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+ outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
v->line.file));
struct flist *fli;
options_p o;
for (v = variables; v; v = v->next)
{
- outf_p f = get_output_file_with_visibility (CONST_CAST (input_file*,
+ outf_p f = get_output_file_with_visibility (const_cast<input_file*> (
v->line.file));
struct flist *fli;
int skip_p = 0;
new_cdata = XNEWVAR (class constraint_data,
sizeof (class constraint_data) + namelen);
new (new_cdata) constraint_data ();
- strcpy (CONST_CAST (char *, new_cdata->name), name);
+ strcpy (const_cast<char *> (new_cdata->name), name);
new_cdata->namelen = namelen;
new_cdata->loc = info->loc;
new_cdata->next_this_letter = *slot;
a STRING_CST. */
gcc_assert (offset == offsetof (struct tree_string, str));
p = ((const char *) p) - offset;
- gt_ggc_mx_lang_tree_node (CONST_CAST (void *, p));
+ gt_ggc_mx_lang_tree_node (const_cast<void *> (p));
return;
}
real_debug_hooks->undef (lineno, buffer);
- mhval.name = CONST_CAST (char *, buffer);
+ mhval.name = const_cast<char *> (buffer);
mhval.value = NULL;
slot = htab_find_slot (macro_hash, &mhval, NO_INSERT);
if (slot != NULL)
slot = htab_find_slot (container->type_hash, type, INSERT);
if (*slot != NULL)
return;
- *slot = CONST_CAST (void *, (const void *) type);
+ *slot = const_cast<void *> ((const void *) type);
if (!go_format_type (container, original_type, true, false,
NULL, false))
{
fprintf (go_dump_file, "// ");
slot = htab_find_slot (container->invalid_hash, type, INSERT);
- *slot = CONST_CAST (void *, (const void *) type);
+ *slot = const_cast<void *> ((const void *) type);
}
fprintf (go_dump_file, "type _%s ",
IDENTIFIER_POINTER (DECL_NAME (decl)));
slot = htab_find_slot (container->type_hash, type, INSERT);
if (*slot != NULL)
return;
- *slot = CONST_CAST (void *, (const void *) type);
+ *slot = const_cast<void *> ((const void *) type);
if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL,
false))
{
fprintf (go_dump_file, "// ");
slot = htab_find_slot (container->invalid_hash, type, INSERT);
- *slot = CONST_CAST (void *, (const void *) type);
+ *slot = const_cast<void *> ((const void *) type);
}
fprintf (go_dump_file, "type _%s ",
IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))));
for (i = 0; i < count; i++)
{
slot = htab_find_slot (container->keyword_hash, keywords[i], INSERT);
- *slot = CONST_CAST (void *, (const void *) keywords[i]);
+ *slot = const_cast<void *> ((const void *) keywords[i]);
}
}
/* The underlying data address has been extracted from the mapping header.
Free that, then free the allocated uncompression buffer. */
(free_section_f) (file_data, section_type, name, header->data, header->len);
- free (CONST_CAST (char *, real_data));
+ free (const_cast<char *> (real_data));
}
/* Free data allocated by lto_get_raw_section_data. */
{
struct lto_renaming_slot *s = (struct lto_renaming_slot *) slot;
- free (CONST_CAST (void *, (const void *) s->old_name));
- free (CONST_CAST (void *, (const void *) s->new_name));
+ free (const_cast<void *> ((const void *) s->old_name));
+ free (const_cast<void *> ((const void *) s->new_name));
free ((void *) s);
}
int exit_status = 0;
int err = 0;
const char *errmsg
- = pex_one (PEX_SEARCH, make_args[0], CONST_CAST (char **, make_args),
+ = pex_one (PEX_SEARCH, make_args[0], const_cast<char **> (make_args),
"make", NULL, NULL, &exit_status, &err);
freeargv (make_argv);
return errmsg == NULL && exit_status == 0 && err == 0;
new_argv = XOBFINISH (&argv_obstack, const char **);
argv_ptr = &new_argv[new_head_argc];
- fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true,
+ fork_execute (new_argv[0], const_cast<char **> (new_argv), true,
"ltrans_args");
/* Copy the early generated debug info from the objects to temporary
snprintf (argsuffix,
sizeof (DUMPBASE_SUFFIX) + sizeof (".ltrans_args"),
"ltrans%u.ltrans_args", i);
- fork_execute (new_argv[0], CONST_CAST (char **, new_argv),
+ fork_execute (new_argv[0], const_cast<char **> (new_argv),
true, save_temps ? argsuffix : NULL);
if (!ltrans_cache)
maybe_unlink (input_names[i]);
obstack_ptr_grow (&argv_obstack, NULL);
new_argv = XOBFINISH (&argv_obstack, const char **);
- pex = collect_execute (new_argv[0], CONST_CAST (char **, new_argv),
+ pex = collect_execute (new_argv[0], const_cast<char **> (new_argv),
NULL, NULL, PEX_SEARCH, false, NULL);
do_wait (new_argv[0], pex);
freeargv (make_argv);
{
struct lto_section_slot *s = (struct lto_section_slot *)arg;
- free (CONST_CAST (char *, s->name));
+ free (const_cast<char *> (s->name));
free (arg);
}
*len = f_slot->len;
}
- free (CONST_CAST (char *, section_name));
+ free (const_cast<char *> (section_name));
return data;
}
munmap ((caddr_t) computed_offset, computed_len);
#else
- free (CONST_CAST(char *, offset));
+ free (const_cast<char *> (offset));
#endif
}
streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL, part);
ipa_write_optimization_summaries (encoder, part == 0);
- free (CONST_CAST (char *, file->filename));
+ free (const_cast<char *> (file->filename));
lto_set_current_out_file (NULL);
lto_obj_file_close (file);
const char *eptr;
errno = 0;
- val = strtol (pos, CONST_CAST (char **, &eptr), 10);
+ val = strtol (pos, const_cast<char **> (&eptr), 10);
if (errno || val <= 0 || (int) val != val)
goto malformed;
pos = eptr;
set_pass_for_id (id, pass);
full_name = concat (prefix, pass->name, num, NULL);
register_pass_name (pass, full_name);
- free (CONST_CAST (char *, full_name));
+ free (const_cast<char *> (full_name));
}
/* Register the dump files for the pass_manager starting at PASS. */
{
if (dump_file_name)
{
- free (CONST_CAST (char *, dump_file_name));
+ free (const_cast<char *> (dump_file_name));
dump_file_name = NULL;
}
}
if (name_is_short)
{
- base_name = CONST_CAST (char*, plugin_name);
+ base_name = const_cast<char*> (plugin_name);
#if defined(__MINGW32__)
static const char plugin_ext[] = ".dll";
result = concat (key, &path[len], NULL);
if (free_key)
- free (CONST_CAST (char *, key));
+ free (const_cast<char *> (key));
result = translate_name (result);
}
else
/* Repeat the whole conversion process as needed with
larger buffers so non-reversible transformations can
always be detected. */
- ICONV_CONST char *inbuf = CONST_CAST (char *, ident);
+ ICONV_CONST char *inbuf = const_cast<char *> (ident);
char *outbuf;
size_t inbytesleft = idlen;
size_t outbytesleft = ret_alloc - 1;
int exit_status = 0;
int err = 0;
pex_one (PEX_SEARCH | PEX_LAST,
- args[0], CONST_CAST (char **, args),
+ args[0], const_cast<char **> (args),
NULL, NULL, NULL, &exit_status, &err);
}
inline void
stats_counter_hasher::remove (statistics_counter *v)
{
- free (CONST_CAST (char *, v->id));
+ free (const_cast<char *> (v->id));
free (v);
}
void
gt_pch_n_S (const void *x)
{
- gt_pch_note_object (CONST_CAST (void *, x), CONST_CAST (void *, x),
+ gt_pch_note_object (const_cast<void *> (x), const_cast<void *> (x),
>_pch_p_S);
}
void
gt_pch_n_S2 (const void *x, size_t string_len)
{
- gt_pch_note_object (CONST_CAST (void *, x), CONST_CAST (void *, x),
+ gt_pch_note_object (const_cast<void *> (x), const_cast<void *> (x),
>_pch_p_S, string_len);
}
#endif /* GCC >= 3.0 */
-/* This macro allows casting away const-ness to pass -Wcast-qual
- warnings. DO NOT USE THIS UNLESS YOU REALLY HAVE TO! It should
- only be used in certain specific cases. One valid case is where
- the C standard definitions or prototypes force you to. E.g. if you
- need to free a const object, or if you pass a const string to
- execv, et al. Another valid use would be in an allocation function
- that creates const objects that need to be initialized. In some
- cases we have non-const functions that return the argument
- (e.g. next_nonnote_insn). Rather than create const shadow
- functions, we can cast away const-ness in calling these interfaces
- if we're careful to verify that the called function does indeed not
- modify its argument and the return value is only used in a const
- context. (This can be somewhat dangerous as these assumptions can
- change after the fact). Beyond these uses, most other cases of
- using this macro should be viewed with extreme caution. */
-
-#ifdef __cplusplus
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))
-#else
-#if defined(__GNUC__) && GCC_VERSION > 4000
-/* GCC 4.0.x has a bug where it may ICE on this expression,
- so does GCC 3.4.x (PR17436). */
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
-#elif defined(__GNUC__)
-inline char *
-helper_const_non_const_cast (const char *p)
-{
- union {
- const char *const_c;
- char *c;
- } val;
- val.const_c = p;
- return val.c;
-}
-
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) \
- ((TOTYPE) helper_const_non_const_cast ((const char *) (FROMTYPE) (X)))
-#else
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
-#endif
-#endif
-#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
-
/* Activate certain diagnostics as warnings (not errors via the
-Werror flag). */
#if GCC_VERSION >= 4003
fn_name = concat ("__gcov_interval_profiler", fn_suffix, NULL);
tree_interval_profiler_fn = build_fn_decl (fn_name,
interval_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_interval_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_interval_profiler_fn)
= tree_cons (get_identifier ("leaf"), NULL,
NULL_TREE);
fn_name = concat ("__gcov_pow2_profiler", fn_suffix, NULL);
tree_pow2_profiler_fn = build_fn_decl (fn_name, pow2_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_pow2_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_pow2_profiler_fn)
= tree_cons (get_identifier ("leaf"), NULL,
fn_name = concat ("__gcov_topn_values_profiler", fn_suffix, NULL);
tree_topn_values_profiler_fn
= build_fn_decl (fn_name, topn_values_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_topn_values_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_topn_values_profiler_fn)
fn_name = concat ("__gcov_indirect_call_profiler_v4", fn_suffix, NULL);
tree_indirect_call_profiler_fn
= build_fn_decl (fn_name, ic_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_indirect_call_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_indirect_call_profiler_fn)
fn_name = concat ("__gcov_average_profiler", fn_suffix, NULL);
tree_average_profiler_fn = build_fn_decl (fn_name,
average_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_average_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_average_profiler_fn)
= tree_cons (get_identifier ("leaf"), NULL,
DECL_ATTRIBUTES (tree_average_profiler_fn));
fn_name = concat ("__gcov_ior_profiler", fn_suffix, NULL);
tree_ior_profiler_fn = build_fn_decl (fn_name, average_profiler_fn_type);
- free (CONST_CAST (char *, fn_name));
+ free (const_cast<char *> (fn_name));
TREE_NOTHROW (tree_ior_profiler_fn) = 1;
DECL_ATTRIBUTES (tree_ior_profiler_fn)
= tree_cons (get_identifier ("leaf"), NULL,
tree_check_failed (__t, __f, __l, __g, TREE_VEC, 0);
if (__i < 0 || __i >= __t->base.u.length)
tree_vec_elt_check_failed (__i, __t->base.u.length, __f, __l, __g);
- return CONST_CAST (const_tree *, &__t->vec.a[__i]);
+ return const_cast<const_tree *> (&__t->vec.a[__i]);
//return &__t->vec.a[__i];
}
tree_check_failed (__t, __f, __l, __g, OMP_CLAUSE, 0);
if (__i < 0 || __i >= omp_clause_num_ops [__t->omp_clause.code])
omp_clause_operand_check_failed (__i, __t, __f, __l, __g);
- return CONST_CAST (const_tree *, &__t->omp_clause.ops[__i]);
+ return const_cast<const_tree *> (&__t->omp_clause.ops[__i]);
}
inline const_tree
const_tree __u = EXPR_CHECK (__t);
if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__u))
tree_operand_check_failed (__i, __u, __f, __l, __g);
- return CONST_CAST (const_tree *, &__u->exp.operands[__i]);
+ return const_cast<const_tree *> (&__u->exp.operands[__i]);
}
inline const_tree *
tree_check_failed (__t, __f, __l, __g, __code, 0);
if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t))
tree_operand_check_failed (__i, __t, __f, __l, __g);
- return CONST_CAST (const_tree *, &__t->exp.operands[__i]);
+ return const_cast<const_tree *> (&__t->exp.operands[__i]);
}
#endif
unreachable default case of a switch. Do not use gcc_assert(0). */
#define gcc_unreachable() (abort ())
-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
-#define CONST_CAST(TYPE,X) CONST_CAST2 (TYPE, const TYPE, (X))
-
/* Filename handling macros. */
#include "filenames.h"
{
if (ix < m_vecpfx.m_num)
{
- *ptr = CONST_CAST (T *, &address ()[ix]);
+ *ptr = const_cast<T *> (&address ()[ix]);
return true;
}
else