From e47a6f81edf98a062ad29cdb62590c1c7fdeb37a Mon Sep 17 00:00:00 2001 From: ghazi Date: Mon, 3 Sep 2007 17:09:20 +0000 Subject: [PATCH] * 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. 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 --- gcc/ChangeLog | 29 +++++++++++++++++++++++++++++ gcc/c-decl.c | 2 +- gcc/c-lex.c | 6 +++--- gcc/c-typeck.c | 2 +- gcc/config/i386/i386.c | 4 ++-- gcc/config/mmix/mmix.c | 2 +- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/call.c | 4 ++-- gcc/cp/decl.c | 2 +- gcc/cp/parser.c | 2 +- gcc/cp/tree.c | 4 ++-- gcc/cp/typeck.c | 6 +++--- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/gfortranspec.c | 2 +- gcc/fortran/options.c | 2 +- gcc/fortran/parse.c | 2 +- gcc/fortran/st.c | 2 +- gcc/gcc.c | 32 ++++++++++++++++---------------- gcc/gengtype-parse.c | 8 ++++---- gcc/gimple-low.c | 2 +- gcc/java/ChangeLog | 6 ++++++ gcc/java/jcf-parse.c | 4 ++-- gcc/java/jcf.h | 4 ++-- gcc/jump.c | 4 ++-- gcc/passes.c | 2 +- gcc/prefix.c | 2 +- gcc/pretty-print.c | 2 +- gcc/rtlanal.c | 2 +- gcc/system.h | 8 ++++++-- gcc/tree-cfg.c | 4 ++-- gcc/tree-eh.c | 2 +- gcc/tree.c | 6 +++--- 32 files changed, 115 insertions(+), 60 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d80882a..3cd2afa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,32 @@ +2007-09-03 Kaveh R. Ghazi + + * 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 * config/netbsd-elf.h (USE_LD_AS_NEEDED): Define. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index d2f4832..e265f67 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2812,7 +2812,7 @@ c_make_fname_decl (tree id, int type_dep) 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; diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 17cb9ed..bc0aeb2 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -187,7 +187,7 @@ cb_ident (cpp_reader * ARG_UNUSED (pfile), 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 @@ -941,7 +941,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) (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) { @@ -962,7 +962,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) *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 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 4d4c4d1..a922081 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1113,7 +1113,7 @@ free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *tu_til) 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; } diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a98dcfb..dba72df 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2972,7 +2972,7 @@ ix86_function_regparm (const_tree type, const_tree decl) && 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; @@ -3054,7 +3054,7 @@ ix86_function_sseregparm (const_tree type, const_tree decl) 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; } diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 38fd072..699a30d 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1141,7 +1141,7 @@ mmix_encode_section_info (tree decl, rtx rtl, int first) 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 = '@'; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4cb5476..f52770d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2007-09-03 Kaveh R. Ghazi + + * 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 PR c++/33208 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4dae84a..8fb818b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5388,7 +5388,7 @@ name_as_c_string (tree name, tree type, bool *free_p) 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 @@ -5409,7 +5409,7 @@ name_as_c_string (tree name, tree type, bool *free_p) *free_p = true; } else - pretty_name = (char *) CONST_CAST (IDENTIFIER_POINTER (name)); + pretty_name = CONST_CAST (char *, IDENTIFIER_POINTER (name)); return pretty_name; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d48d0fa..fba084d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3461,7 +3461,7 @@ cp_make_fname_decl (tree id, int type_dep) 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; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 92f4430..d39721e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2923,7 +2923,7 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok) (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); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3424f7a..9a1ad13 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2054,7 +2054,7 @@ pod_type_p (const_tree t) { /* 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; @@ -2093,7 +2093,7 @@ zero_init_p (const_tree t) { /* 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; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ae39b59..45988db 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6946,7 +6946,7 @@ cp_type_quals (const_tree 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)); if (type == error_mark_node) return TYPE_UNQUALIFIED; return TYPE_QUALS (type); @@ -6960,7 +6960,7 @@ cp_type_readonly (const_tree 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); } @@ -6971,7 +6971,7 @@ cp_has_mutable_p (const_tree 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); } diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ce57c13..f3f460a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2007-09-03 Kaveh R. Ghazi + + * 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 PR fortran/31675 diff --git a/gcc/fortran/gfortranspec.c b/gcc/fortran/gfortranspec.c index dc4dcde..be98303 100644 --- a/gcc/fortran/gfortranspec.c +++ b/gcc/fortran/gfortranspec.c @@ -302,7 +302,7 @@ lang_specific_driver (int *in_argc, const char *const **in_argv, 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. diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index a68c3be..2d11ad7 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -244,7 +244,7 @@ gfc_post_options (const char **pfilename) 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. */ diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index df7f68f..38e62cd 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -2636,7 +2636,7 @@ parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only) && 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] diff --git a/gcc/fortran/st.c b/gcc/fortran/st.c index 8084453..777e4eb 100644 --- a/gcc/fortran/st.c +++ b/gcc/fortran/st.c @@ -173,7 +173,7 @@ gfc_free_statement (gfc_code *p) 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: diff --git a/gcc/gcc.c b/gcc/gcc.c index c7c3cf3..99bcd78 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1888,7 +1888,7 @@ set_spec (const char *name, const char *spec) /* 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; } @@ -2193,7 +2193,7 @@ read_specs (const char *filename, int main_p) 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; @@ -2543,18 +2543,18 @@ for_each_path (const struct path_prefix *paths, 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 @@ -2563,12 +2563,12 @@ for_each_path (const struct path_prefix *paths, 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; @@ -2985,7 +2985,7 @@ execute (void) 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) { @@ -2999,7 +2999,7 @@ execute (void) } if (string != commands[i].prog) - free (CONST_CAST (string)); + free (CONST_CAST (char *, string)); } execution_count++; @@ -5041,7 +5041,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) 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; @@ -5997,13 +5997,13 @@ give_switch (int switchnum, int omit_first_word) 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 @@ -7456,7 +7456,7 @@ set_multilib_dir (void) 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) diff --git a/gcc/gengtype-parse.c b/gcc/gengtype-parse.c index 4d546f3..357981a 100644 --- a/gcc/gengtype-parse.c +++ b/gcc/gengtype-parse.c @@ -197,9 +197,9 @@ string_seq (void) 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; @@ -221,8 +221,8 @@ typedef_name (void) 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 diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index 74f9ffb..6de6eae 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -398,7 +398,7 @@ block_may_fallthru (const_tree block) { /* 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) { diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index b69d19a..fcbb9db 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2007-09-03 Kaveh R. Ghazi + + * jcf-parse.c (read_class, java_parse_file): Supply a TYPE for + CONST_CAST. + * jcf.h (JCF_FINISH): Likewise. + 2007-08-28 Tom Tromey * Make-lang.in (java.tags): Don't tag '*.y' files. diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 08d5136..397b187 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -1301,7 +1301,7 @@ read_class (tree name) if (path_name == 0) return 0; else - free(CONST_CAST (path_name)); + free(CONST_CAST (char *, path_name)); } current_jcf = jcf; @@ -1778,7 +1778,7 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) file_list = list; } else - list = (char *) CONST_CAST (main_input_filename); + list = CONST_CAST (char *, main_input_filename); while (list) { diff --git a/gcc/java/jcf.h b/gcc/java/jcf.h index af9dadd..d4de2c5 100644 --- a/gcc/java/jcf.h +++ b/gcc/java/jcf.h @@ -164,8 +164,8 @@ typedef struct JCF GTY(()) { #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) \ diff --git a/gcc/jump.c b/gcc/jump.c index 7a040d1..cd51764 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -302,9 +302,9 @@ reversed_comparison_code_parts (enum rtx_code code, const_rtx arg0, /* 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 diff --git a/gcc/passes.c b/gcc/passes.c index 1a34752..e2f0676 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1136,7 +1136,7 @@ execute_one_pass (struct tree_opt_pass *pass) /* 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; } diff --git a/gcc/prefix.c b/gcc/prefix.c index 07d8782..c72203c 100644 --- a/gcc/prefix.c +++ b/gcc/prefix.c @@ -266,7 +266,7 @@ update_path (const char *path, const char *key) result = concat (key, &path[len], NULL); if (free_key) - free (CONST_CAST (key)); + free (CONST_CAST (char *, key)); result = translate_name (result); } else diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 2b04dc7..8f55df2 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -633,7 +633,7 @@ pp_base_destroy_prefix (pretty_printer *pp) { if (pp->prefix != NULL) { - free (CONST_CAST (pp->prefix)); + free (CONST_CAST (char *, pp->prefix)); pp->prefix = NULL; } } diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 1d90a12..3c4331e 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -3395,7 +3395,7 @@ keep_with_call_p (const_rtx insn) /* 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; } diff --git a/gcc/system.h b/gcc/system.h index c90ded1..1696b9c 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -784,10 +784,14 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; #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 diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 947b8de..b01d7ab 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -1160,7 +1160,7 @@ tree_can_merge_blocks_p (const_basic_block a, const_basic_block b) 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; @@ -5922,7 +5922,7 @@ tree_block_ends_with_condjump_p (const_basic_block bb) { /* 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); } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 8b195d7..f8aed14 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -157,7 +157,7 @@ lookup_stmt_eh_region_fn (struct function *ifun, const_tree t) /* 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); diff --git a/gcc/tree.c b/gcc/tree.c index d04c1f0..289b5c9 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1194,8 +1194,8 @@ build_string (int len, const char *str) 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; } @@ -4795,7 +4795,7 @@ attribute_list_contained (const_tree l1, const_tree l2) 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))) -- 2.7.4