CONST_CAST_BB): New macros for type-specific casts.
(CONST_CAST): Add a TYPE parameter and define it in terms of
CONST_CAST2.
* c-decl.c (c_make_fname_decl): Supply a TYPE for CONST_CAST.
* c-lex.c (cb_ident, lex_string): Likewise,
* c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise,
* config/i386/i386.c (ix86_function_regparm,
ix86_function_sseregparm): Use CONST_CAST_TREE.
* config/mmix/mmix.c (mmix_encode_section_info): Supply a TYPE for
CONST_CAST.
* gcc.c (set_spec, read_specs, for_each_path, execute, do_spec_1,
give_switch, set_multilib_dir): Likewise,
* gengtype-parse.c (string_seq, typedef_name): Likewise,
* gimple-low.c (block_may_fallthru): Use CONST_CAST_TREE.
* jump.c (reversed_comparison_code_parts): Use CONST_CAST_RTX.
* passes.c (execute_one_pass): Supply a TYPE for CONST_CAST.
* prefix.c (update_path): Likewise,
* pretty-print.c (pp_base_destroy_prefix): Likewise,
* rtlanal.c (keep_with_call_p): Use CONST_CAST_RTX.
* tree-cfg.c (tree_can_merge_blocks_p,
tree_block_ends_with_condjump_p): Use CONST_CAST_BB.
* tree-eh.c (lookup_stmt_eh_region_fn): USe CONST_CAST_TREE.
* tree.c (build_string): Supply a TYPE for CONST_CAST.
(attribute_list_contained): Use CONST_CAST_TREE.
cp:
* call.c (name_as_c_string): Supply a TYPE for CONST_CAST.
* decl.c (cp_make_fname_decl): Likewise,
* parser.c (cp_parser_string_literal): Likewise,
* tree.c (pod_type_p, zero_init_p): Use CONST_CAST_TREE.
* typeck.c (cp_type_quals, cp_type_readonly, cp_has_mutable_p):
Likewise,
fortran:
* gfortranspec.c (lang_specific_driver): Use CONST_CAST2.
* options.c (gfc_post_options): Supply a TYPE for CONST_CAST.
* parse.c (parse_omp_structured_block): Likewise,
* st.c (gfc_free_statement): Likewise,
java:
* jcf-parse.c (read_class, java_parse_file): Supply a TYPE for
CONST_CAST.
* jcf.h (JCF_FINISH): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128051
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-09-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * system.h (CONST_CAST2, CONST_CAST_TREE, CONST_CAST_RTX,
+ CONST_CAST_BB): New macros for type-specific casts.
+ (CONST_CAST): Add a TYPE parameter and define it in terms of
+ CONST_CAST2.
+
+ * c-decl.c (c_make_fname_decl): Supply a TYPE for CONST_CAST.
+ * c-lex.c (cb_ident, lex_string): Likewise,
+ * c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise,
+ * config/i386/i386.c (ix86_function_regparm,
+ ix86_function_sseregparm): Use CONST_CAST_TREE.
+ * config/mmix/mmix.c (mmix_encode_section_info): Supply a TYPE for
+ CONST_CAST.
+ * gcc.c (set_spec, read_specs, for_each_path, execute, do_spec_1,
+ give_switch, set_multilib_dir): Likewise,
+ * gengtype-parse.c (string_seq, typedef_name): Likewise,
+ * gimple-low.c (block_may_fallthru): Use CONST_CAST_TREE.
+ * jump.c (reversed_comparison_code_parts): Use CONST_CAST_RTX.
+ * passes.c (execute_one_pass): Supply a TYPE for CONST_CAST.
+ * prefix.c (update_path): Likewise,
+ * pretty-print.c (pp_base_destroy_prefix): Likewise,
+ * rtlanal.c (keep_with_call_p): Use CONST_CAST_RTX.
+ * tree-cfg.c (tree_can_merge_blocks_p,
+ tree_block_ends_with_condjump_p): Use CONST_CAST_BB.
+ * tree-eh.c (lookup_stmt_eh_region_fn): USe CONST_CAST_TREE.
+ * tree.c (build_string): Supply a TYPE for CONST_CAST.
+ (attribute_list_contained): Use CONST_CAST_TREE.
+
2007-09-03 Krister Walfridsson <cato@df.lth.se>
* config/netbsd-elf.h (USE_LD_AS_NEEDED): Define.
DECL_ARTIFICIAL (decl) = 1;
init = build_string (length + 1, name);
- free (CONST_CAST (name));
+ free (CONST_CAST (char *, name));
TREE_TYPE (init) = type;
DECL_INITIAL (decl) = init;
if (cpp_interpret_string (pfile, str, 1, &cstr, false))
{
ASM_OUTPUT_IDENT (asm_out_file, (const char *) cstr.text);
- free (CONST_CAST (cstr.text));
+ free (CONST_CAST (unsigned char *, cstr.text));
}
}
#endif
(parse_in, strs, concats + 1, &istr, wide))
{
value = build_string (istr.len, (const char *) istr.text);
- free (CONST_CAST (istr.text));
+ free (CONST_CAST (unsigned char *, istr.text));
if (c_lex_string_translate == -1)
{
*valp = build_string (istr.len, (const char *) istr.text);
valp = &TREE_CHAIN (*valp);
}
- free (CONST_CAST (istr.text));
+ free (CONST_CAST (unsigned char *, istr.text));
}
}
else
const struct tagged_tu_seen_cache *const tu1
= (const struct tagged_tu_seen_cache *) tu;
tu = tu1->next;
- free (CONST_CAST (tu1));
+ free (CONST_CAST (struct tagged_tu_seen_cache *, tu1));
}
tagged_tu_seen_base = tu_til;
}
&& flag_unit_at_a_time && !profile_flag)
{
/* FIXME: remove this CONST_CAST when cgraph.[ch] is constified. */
- struct cgraph_local_info *i = cgraph_local_info ((tree)CONST_CAST(decl));
+ struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
if (i && i->local)
{
int local_regparm, globals = 0, regno;
if (decl && TARGET_SSE_MATH && flag_unit_at_a_time && !profile_flag)
{
/* FIXME: remove this CONST_CAST when cgraph.[ch] is constified. */
- struct cgraph_local_info *i = cgraph_local_info ((tree)CONST_CAST(decl));
+ struct cgraph_local_info *i = cgraph_local_info (CONST_CAST_TREE(decl));
if (i && i->local)
return TARGET_SSE2 ? 2 : 1;
}
char *newstr;
/* Why is the return type of ggc_alloc_string const? */
- newstr = (char *) CONST_CAST (ggc_alloc_string ("", len + 1));
+ newstr = CONST_CAST (char *, ggc_alloc_string ("", len + 1));
strcpy (newstr + 1, str);
*newstr = '@';
+2007-09-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * call.c (name_as_c_string): Supply a TYPE for CONST_CAST.
+ * decl.c (cp_make_fname_decl): Likewise,
+ * parser.c (cp_parser_string_literal): Likewise,
+ * tree.c (pod_type_p, zero_init_p): Use CONST_CAST_TREE.
+ * typeck.c (cp_type_quals, cp_type_readonly, cp_has_mutable_p):
+ Likewise,
+
2007-09-02 Paolo Carlini <pcarlini@suse.de>
PR c++/33208
if (IDENTIFIER_CTOR_OR_DTOR_P (name))
{
pretty_name
- = (char *) CONST_CAST (IDENTIFIER_POINTER (constructor_name (type)));
+ = CONST_CAST (char *, IDENTIFIER_POINTER (constructor_name (type)));
/* For a destructor, add the '~'. */
if (name == complete_dtor_identifier
|| name == base_dtor_identifier
*free_p = true;
}
else
- pretty_name = (char *) CONST_CAST (IDENTIFIER_POINTER (name));
+ pretty_name = CONST_CAST (char *, IDENTIFIER_POINTER (name));
return pretty_name;
}
tree decl = build_decl (VAR_DECL, id, type);
if (name)
- free (CONST_CAST (name));
+ free (CONST_CAST (char *, name));
/* As we're using pushdecl_with_scope, we must set the context. */
DECL_CONTEXT (decl) = current_function_decl;
(parse_in, strs, count, &istr, wide))
{
value = build_string (istr.len, (const char *)istr.text);
- free (CONST_CAST (istr.text));
+ free (CONST_CAST (unsigned char *, istr.text));
TREE_TYPE (value) = wide ? wchar_array_type_node : char_array_type_node;
value = fix_string_type (value);
{
/* This CONST_CAST is okay because strip_array_types returns it's
argument unmodified and we assign it to a const_tree. */
- t = strip_array_types ((tree)CONST_CAST(t));
+ t = strip_array_types (CONST_CAST_TREE(t));
if (t == error_mark_node)
return 1;
{
/* This CONST_CAST is okay because strip_array_types returns it's
argument unmodified and we assign it to a const_tree. */
- t = strip_array_types ((tree)CONST_CAST(t));
+ t = strip_array_types (CONST_CAST_TREE(t));
if (t == error_mark_node)
return 1;
{
/* This CONST_CAST is okay because strip_array_types returns it's
argument unmodified and we assign it to a const_tree. */
- type = strip_array_types ((tree)CONST_CAST(type));
+ type = strip_array_types (CONST_CAST_TREE(type));
if (type == error_mark_node)
return TYPE_UNQUALIFIED;
return TYPE_QUALS (type);
{
/* This CONST_CAST is okay because strip_array_types returns it's
argument unmodified and we assign it to a const_tree. */
- type = strip_array_types ((tree)CONST_CAST(type));
+ type = strip_array_types (CONST_CAST_TREE(type));
return TYPE_READONLY (type);
}
{
/* This CONST_CAST is okay because strip_array_types returns it's
argument unmodified and we assign it to a const_tree. */
- type = strip_array_types ((tree)CONST_CAST(type));
+ type = strip_array_types (CONST_CAST_TREE(type));
return CLASS_TYPE_P (type) && CLASSTYPE_HAS_MUTABLE (type);
}
+2007-09-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * gfortranspec.c (lang_specific_driver): Use CONST_CAST2.
+ * options.c (gfc_post_options): Supply a TYPE for CONST_CAST.
+ * parse.c (parse_omp_structured_block): Likewise,
+ * st.c (gfc_free_statement): Likewise,
+
2007-09-03 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31675
g77_xargc = argc;
g77_xargv = argv;
g77_newargc = 0;
- g77_newargv = (const char **) CONST_CAST (argv);
+ g77_newargv = CONST_CAST2 (const char **, const char *const *, argv);
/* First pass through arglist.
gfc_add_include_path (".", true);
if (canon_source_file != gfc_source_file)
- gfc_free (CONST_CAST (canon_source_file));
+ gfc_free (CONST_CAST (char *, canon_source_file));
/* Decide which form the file will be read in as. */
&& strcmp (cp->ext.omp_name, new_st.ext.omp_name) != 0))
gfc_error ("Name after !$omp critical and !$omp end critical does "
"not match at %C");
- gfc_free (CONST_CAST (new_st.ext.omp_name));
+ gfc_free (CONST_CAST (char *, new_st.ext.omp_name));
break;
case EXEC_OMP_END_SINGLE:
cp->ext.omp_clauses->lists[OMP_LIST_COPYPRIVATE]
break;
case EXEC_OMP_CRITICAL:
- gfc_free (CONST_CAST (p->ext.omp_name));
+ gfc_free (CONST_CAST (char *, p->ext.omp_name));
break;
case EXEC_OMP_FLUSH:
/* Free the old spec. */
if (old_spec && sl->alloc_p)
- free (CONST_CAST(old_spec));
+ free (CONST_CAST(char *, old_spec));
sl->alloc_p = 1;
}
set_spec (p2, *(sl->ptr_spec));
if (sl->alloc_p)
- free (CONST_CAST (*(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 (multi_dir));
+ free (CONST_CAST (char *, multi_dir));
multi_dir = NULL;
- free (CONST_CAST (multi_suffix));
+ free (CONST_CAST (char *, multi_suffix));
multi_suffix = machine_suffix;
- free (CONST_CAST (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 (multi_os_dir));
+ free (CONST_CAST (char *, multi_os_dir));
multi_os_dir = NULL;
}
else
if (multi_dir)
{
- free (CONST_CAST (multi_dir));
- free (CONST_CAST (multi_suffix));
- free (CONST_CAST (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 (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, (char * const *) CONST_CAST (commands[i].argv),
+ string, CONST_CAST (char **, commands[i].argv),
NULL, NULL, &err);
if (errmsg != NULL)
{
}
if (string != commands[i].prog)
- free (CONST_CAST (string));
+ free (CONST_CAST (char *, string));
}
execution_count++;
for (i = 0, j = 0; i < max; i++)
if (outfiles[i])
{
- argv[j] = (char *) CONST_CAST (outfiles[i]);
+ argv[j] = CONST_CAST (char *, outfiles[i]);
j++;
}
argv[j] = NULL;
while (length-- && !IS_DIR_SEPARATOR (arg[length]))
if (arg[length] == '.')
{
- ((char *)CONST_CAST(arg))[length] = 0;
+ (CONST_CAST(char *, arg))[length] = 0;
dot = 1;
break;
}
do_spec_1 (arg, 1, NULL);
if (dot)
- ((char *)CONST_CAST(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 (multilib_os_dir));
+ free (CONST_CAST (char *, multilib_os_dir));
multilib_os_dir = NULL;
}
else if (multilib_dir != NULL && multilib_os_dir == NULL)
l1 = strlen (s1);
l2 = strlen (s2);
- buf = XRESIZEVEC (char, CONST_CAST(s1), l1 + l2 + 1);
+ buf = XRESIZEVEC (char, CONST_CAST(char *, s1), l1 + l2 + 1);
memcpy (buf + l1, s2, l2 + 1);
- XDELETE (CONST_CAST (s2));
+ XDELETE (CONST_CAST (char *, s2));
s1 = buf;
}
return s1;
c2 = require (ID);
require (')');
r = concat ("VEC_", c1, "_", c2, (char *)0);
- free (CONST_CAST (c1));
- free (CONST_CAST (c2));
+ free (CONST_CAST (char *, c1));
+ free (CONST_CAST (char *, c2));
return r;
}
else
{
/* This CONST_CAST is okay because expr_last returns it's argument
unmodified and we assign it to a const_tree. */
- const_tree stmt = expr_last ((tree)CONST_CAST(block));
+ const_tree stmt = expr_last (CONST_CAST_TREE(block));
switch (stmt ? TREE_CODE (stmt) : ERROR_MARK)
{
+2007-09-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * jcf-parse.c (read_class, java_parse_file): Supply a TYPE for
+ CONST_CAST.
+ * jcf.h (JCF_FINISH): Likewise.
+
2007-08-28 Tom Tromey <tromey@redhat.com>
* Make-lang.in (java.tags): Don't tag '*.y' files.
if (path_name == 0)
return 0;
else
- free(CONST_CAST (path_name));
+ free(CONST_CAST (char *, path_name));
}
current_jcf = jcf;
file_list = list;
}
else
- list = (char *) CONST_CAST (main_input_filename);
+ list = CONST_CAST (char *, main_input_filename);
while (list)
{
#define JCF_FINISH(JCF) { \
CPOOL_FINISH(&(JCF)->cpool); \
if ((JCF)->buffer) free ((JCF)->buffer); \
- if ((JCF)->filename) free (CONST_CAST ((JCF)->filename)); \
- if ((JCF)->classname) free (CONST_CAST ((JCF)->classname)); \
+ if ((JCF)->filename) free (CONST_CAST (char *, (JCF)->filename)); \
+ if ((JCF)->classname) free (CONST_CAST (char *, (JCF)->classname)); \
(JCF)->finished = 1; }
#define CPOOL_INIT(CPOOL) \
/* These CONST_CAST's are okay because prev_nonnote_insn just
returns it's argument and we assign it to a const_rtx
variable. */
- for (prev = prev_nonnote_insn ((rtx)(CONST_CAST(insn)));
+ for (prev = prev_nonnote_insn (CONST_CAST_RTX(insn));
prev != 0 && !LABEL_P (prev);
- prev = prev_nonnote_insn ((rtx)(CONST_CAST(prev))))
+ prev = prev_nonnote_insn (CONST_CAST_RTX(prev)))
{
const_rtx set = set_of (arg0, prev);
if (set && GET_CODE (set) == SET
/* Flush and close dump file. */
if (dump_file_name)
{
- free (CONST_CAST (dump_file_name));
+ free (CONST_CAST (char *, dump_file_name));
dump_file_name = NULL;
}
result = concat (key, &path[len], NULL);
if (free_key)
- free (CONST_CAST (key));
+ free (CONST_CAST (char *, key));
result = translate_name (result);
}
else
{
if (pp->prefix != NULL)
{
- free (CONST_CAST (pp->prefix));
+ free (CONST_CAST (char *, pp->prefix));
pp->prefix = NULL;
}
}
/* This CONST_CAST is okay because next_nonnote_insn just
returns it's argument and we assign it to a const_rtx
variable. */
- const_rtx i2 = next_nonnote_insn ((rtx)CONST_CAST(insn));
+ const_rtx i2 = next_nonnote_insn (CONST_CAST_RTX(insn));
if (i2 && keep_with_call_p (i2))
return true;
}
#if defined(__GNUC__) && GCC_VERSION != 4000
/* GCC 4.0.x has a bug where it may ICE on this expression. */
-#define CONST_CAST(X) ((__extension__(union {__typeof(X)_q; void *_v;})(X))._v)
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
#else
-#define CONST_CAST(X) ((void*)(X))
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
#endif
+#define CONST_CAST(TYPE,X) CONST_CAST2(TYPE, const TYPE, (X))
+#define CONST_CAST_TREE(X) CONST_CAST(union tree_node *, (X))
+#define CONST_CAST_RTX(X) CONST_CAST(struct rtx_def *, (X))
+#define CONST_CAST_BB(X) CONST_CAST(struct basic_block_def *, (X))
/* Activate -Wcast-qual as a warning (not an error/-Werror). */
#if GCC_VERSION >= 4003
cannot merge the blocks. */
/* This CONST_CAST is okay because last_stmt doesn't modify its
argument and the return value is assign to a const_tree. */
- stmt = last_stmt ((basic_block)CONST_CAST(a));
+ stmt = last_stmt (CONST_CAST_BB(a));
if (stmt && stmt_ends_bb_p (stmt))
return false;
{
/* This CONST_CAST is okay because last_stmt doesn't modify its
argument and the return value is not modified. */
- const_tree stmt = last_stmt ((basic_block)CONST_CAST(bb));
+ const_tree stmt = last_stmt (CONST_CAST_BB(bb));
return (stmt && TREE_CODE (stmt) == COND_EXPR);
}
/* The CONST_CAST is okay because we don't modify n.stmt throughout
its scope, or the scope of p. */
- n.stmt = (tree) CONST_CAST (t);
+ n.stmt = CONST_CAST_TREE (t);
p = (struct throw_stmt_node *) htab_find (get_eh_throw_stmt_table (ifun),
&n);
TREE_CONSTANT (s) = 1;
TREE_INVARIANT (s) = 1;
TREE_STRING_LENGTH (s) = len;
- memcpy (CONST_CAST (TREE_STRING_POINTER (s)), str, len);
- ((char *) CONST_CAST (TREE_STRING_POINTER (s)))[len] = '\0';
+ memcpy (s->string.str, str, len);
+ s->string.str[len] = '\0';
return s;
}
modify its argument and the return value is assigned to a
const_tree. */
for (attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)),
- (tree)CONST_CAST(l1));
+ CONST_CAST_TREE(l1));
attr != NULL_TREE;
attr = lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (t2)),
TREE_CHAIN (attr)))