From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3767 invoked by alias); 28 Jul 2007 14:54:31 -0000 Received: (qmail 3759 invoked by uid 22791); 28 Jul 2007 14:54:29 -0000 X-Spam-Check-By: sourceware.org Received: from caip.rutgers.edu (HELO caip.rutgers.edu) (128.6.236.16) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 28 Jul 2007 14:54:25 +0000 Received: from caipclassic.rutgers.edu (caipclassic.rutgers.edu [128.6.237.54]) by caip.rutgers.edu (8.13.8/8.13.5) with ESMTP id l6SEsJwh019762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 28 Jul 2007 10:54:19 -0400 Date: Sat, 28 Jul 2007 15:20:00 -0000 From: "Kaveh R. GHAZI" To: gcc-patches@gcc.gnu.org Subject: [PATCH INSTALLED]: const typedefs part 9/N Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg02036.txt.bz2 This patch adds a few more constifications. Tested on sparc-sun-solaris2.10, no regressions. Installed. --Kaveh 2007-07-27 Kaveh R. Ghazi * calls.c (special_function_p, setjmp_call_p, alloca_call_p, flags_from_decl_or_type): Constify. * gcc.c (do_spec_1): Likewise. * print-tree.c (dump_addr, print_node_brief): Likewise. * tree-cfg.c (stmt_starts_bb_p, is_ctrl_stmt, computed_goto_p, simple_goto_p, tree_can_make_abnormal_goto, stmt_starts_bb_p, tree_purge_all_dead_eh_edges): Likewise. * tree-flow.h (is_ctrl_stmt, computed_goto_p, simple_goto_p, tree_can_make_abnormal_goto, tree_purge_all_dead_eh_edges): Likewise. * tree.c (expr_location, expr_has_location, expr_locus, expr_filename, expr_lineno, get_inner_array_type, fields_compatible_p): Likewise. * tree.h (get_inner_array_type, fields_compatible_p, expr_location, expr_has_location, expr_locus, expr_filename, expr_lineno, dump_addr, print_node_brief, flags_from_decl_or_type, setjmp_call_p, alloca_call_p): Likewise. diff -rup orig/egcc-SVN20070727/gcc/calls.c egcc-SVN20070727/gcc/calls.c --- orig/egcc-SVN20070727/gcc/calls.c 2007-07-26 23:03:57.000000000 -0400 +++ egcc-SVN20070727/gcc/calls.c 2007-07-27 14:59:39.473004526 -0400 @@ -143,7 +143,7 @@ static void load_register_parameters (st int, int *); static rtx emit_library_call_value_1 (int, rtx, rtx, enum libcall_type, enum machine_mode, int, va_list); -static int special_function_p (tree, int); +static int special_function_p (const_tree, int); static int check_sibcall_argument_overlap_1 (rtx); static int check_sibcall_argument_overlap (rtx, struct arg_data *, int); @@ -469,7 +469,7 @@ emit_call_1 (rtx funexp, tree fntree, tr space from the stack such as alloca. */ static int -special_function_p (tree fndecl, int flags) +special_function_p (const_tree fndecl, int flags) { if (fndecl && DECL_NAME (fndecl) && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) <= 17 @@ -543,14 +543,14 @@ special_function_p (tree fndecl, int fla /* Return nonzero when FNDECL represents a call to setjmp. */ int -setjmp_call_p (tree fndecl) +setjmp_call_p (const_tree fndecl) { return special_function_p (fndecl, 0) & ECF_RETURNS_TWICE; } /* Return true when exp contains alloca call. */ bool -alloca_call_p (tree exp) +alloca_call_p (const_tree exp) { if (TREE_CODE (exp) == CALL_EXPR && TREE_CODE (CALL_EXPR_FN (exp)) == ADDR_EXPR @@ -564,10 +564,10 @@ alloca_call_p (tree exp) /* Detect flags (function attributes) from the function decl or type node. */ int -flags_from_decl_or_type (tree exp) +flags_from_decl_or_type (const_tree exp) { int flags = 0; - tree type = exp; + const_tree type = exp; if (DECL_P (exp)) { diff -rup orig/egcc-SVN20070727/gcc/gcc.c egcc-SVN20070727/gcc/gcc.c --- orig/egcc-SVN20070727/gcc/gcc.c 2007-07-26 23:03:38.000000000 -0400 +++ egcc-SVN20070727/gcc/gcc.c 2007-07-27 14:59:39.485401845 -0400 @@ -4847,12 +4847,14 @@ do_spec_1 (const char *spec, int inswitc if (save_temps_flag) { + char *tmp; + temp_filename_length = basename_length + suffix_length; - temp_filename = alloca (temp_filename_length + 1); - strncpy ((char *) temp_filename, input_basename, basename_length); - strncpy ((char *) temp_filename + basename_length, suffix, - suffix_length); - *((char *) temp_filename + temp_filename_length) = '\0'; + tmp = alloca (temp_filename_length + 1); + strncpy (tmp, input_basename, basename_length); + strncpy (tmp + basename_length, suffix, suffix_length); + tmp[temp_filename_length] = '\0'; + temp_filename = tmp; if (strcmp (temp_filename, input_filename) != 0) { #ifndef HOST_LACKS_INODE_NUMBERS diff -rup orig/egcc-SVN20070727/gcc/print-tree.c egcc-SVN20070727/gcc/print-tree.c --- orig/egcc-SVN20070727/gcc/print-tree.c 2007-07-26 23:04:03.000000000 -0400 +++ egcc-SVN20070727/gcc/print-tree.c 2007-07-27 14:59:39.487970273 -0400 @@ -58,7 +58,7 @@ debug_tree (tree node) /* Print PREFIX and ADDR to FILE. */ void -dump_addr (FILE *file, const char *prefix, void *addr) +dump_addr (FILE *file, const char *prefix, const void *addr) { if (flag_dump_noaddr || flag_dump_unnumbered) fprintf (file, "%s#", prefix); @@ -69,7 +69,7 @@ dump_addr (FILE *file, const char *prefi /* Print a node in brief fashion, with just the code, address and name. */ void -print_node_brief (FILE *file, const char *prefix, tree node, int indent) +print_node_brief (FILE *file, const char *prefix, const_tree node, int indent) { enum tree_code_class class; diff -rup orig/egcc-SVN20070727/gcc/tree-cfg.c egcc-SVN20070727/gcc/tree-cfg.c --- orig/egcc-SVN20070727/gcc/tree-cfg.c 2007-07-26 23:04:10.000000000 -0400 +++ egcc-SVN20070727/gcc/tree-cfg.c 2007-07-27 14:59:39.496736920 -0400 @@ -96,7 +96,7 @@ static edge tree_try_redirect_by_replaci static unsigned int split_critical_edges (void); /* Various helpers. */ -static inline bool stmt_starts_bb_p (tree, tree); +static inline bool stmt_starts_bb_p (const_tree, const_tree); static int tree_verify_flow_info (void); static void tree_make_forwarder_block (edge); static void tree_cfg2vcg (FILE *); @@ -2421,7 +2421,7 @@ tree_cfg2vcg (FILE *file) /* Return true if T represents a stmt that always transfers control. */ bool -is_ctrl_stmt (tree t) +is_ctrl_stmt (const_tree t) { return (TREE_CODE (t) == COND_EXPR || TREE_CODE (t) == SWITCH_EXPR @@ -2465,7 +2465,7 @@ is_ctrl_altering_stmt (tree t) /* Return true if T is a computed goto. */ bool -computed_goto_p (tree t) +computed_goto_p (const_tree t) { return (TREE_CODE (t) == GOTO_EXPR && TREE_CODE (GOTO_DESTINATION (t)) != LABEL_DECL); @@ -2475,7 +2475,7 @@ computed_goto_p (tree t) /* Return true if T is a simple local goto. */ bool -simple_goto_p (tree t) +simple_goto_p (const_tree t) { return (TREE_CODE (t) == GOTO_EXPR && TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL); @@ -2486,7 +2486,7 @@ simple_goto_p (tree t) Transfers of control flow associated with EH are excluded. */ bool -tree_can_make_abnormal_goto (tree t) +tree_can_make_abnormal_goto (const_tree t) { if (computed_goto_p (t)) return true; @@ -2507,7 +2507,7 @@ tree_can_make_abnormal_goto (tree t) unnecessary basic blocks that only contain a single label. */ static inline bool -stmt_starts_bb_p (tree t, tree prev_t) +stmt_starts_bb_p (const_tree t, const_tree prev_t) { if (t == NULL_TREE) return false; @@ -6242,7 +6242,7 @@ tree_purge_dead_eh_edges (basic_block bb } bool -tree_purge_all_dead_eh_edges (bitmap blocks) +tree_purge_all_dead_eh_edges (const_bitmap blocks) { bool changed = false; unsigned i; diff -rup orig/egcc-SVN20070727/gcc/tree-flow.h egcc-SVN20070727/gcc/tree-flow.h --- orig/egcc-SVN20070727/gcc/tree-flow.h 2007-07-26 23:04:09.000000000 -0400 +++ egcc-SVN20070727/gcc/tree-flow.h 2007-07-27 14:59:39.499628622 -0400 @@ -722,11 +722,11 @@ extern void free_omp_regions (void); extern void delete_tree_cfg_annotations (void); extern bool stmt_ends_bb_p (tree); -extern bool is_ctrl_stmt (tree); +extern bool is_ctrl_stmt (const_tree); extern bool is_ctrl_altering_stmt (tree); -extern bool computed_goto_p (tree); -extern bool simple_goto_p (tree); -extern bool tree_can_make_abnormal_goto (tree); +extern bool computed_goto_p (const_tree); +extern bool simple_goto_p (const_tree); +extern bool tree_can_make_abnormal_goto (const_tree); extern basic_block single_noncomplex_succ (basic_block bb); extern void tree_dump_bb (basic_block, FILE *, int); extern void debug_tree_bb (basic_block); @@ -762,7 +762,7 @@ extern void add_phi_args_after_copy_bb ( extern void add_phi_args_after_copy (basic_block *, unsigned); extern bool tree_purge_dead_abnormal_call_edges (basic_block); extern bool tree_purge_dead_eh_edges (basic_block); -extern bool tree_purge_all_dead_eh_edges (bitmap); +extern bool tree_purge_all_dead_eh_edges (const_bitmap); extern tree gimplify_val (block_stmt_iterator *, tree, tree); extern tree gimplify_build1 (block_stmt_iterator *, enum tree_code, tree, tree); diff -rup orig/egcc-SVN20070727/gcc/tree.c egcc-SVN20070727/gcc/tree.c --- orig/egcc-SVN20070727/gcc/tree.c 2007-07-26 23:03:31.000000000 -0400 +++ egcc-SVN20070727/gcc/tree.c 2007-07-27 14:59:39.509825196 -0400 @@ -3429,7 +3429,7 @@ annotate_with_locus (tree node, location decls and constants can be shared among multiple locations, so return nothing. */ location_t -expr_location (tree node) +expr_location (const_tree node) { #ifdef USE_MAPPED_LOCATION if (GIMPLE_STMT_P (node)) @@ -3457,7 +3457,7 @@ set_expr_location (tree node, location_t } bool -expr_has_location (tree node) +expr_has_location (const_tree node) { #ifdef USE_MAPPED_LOCATION return expr_location (node) != UNKNOWN_LOCATION; @@ -3471,7 +3471,7 @@ source_location * #else source_locus #endif -expr_locus (tree node) +expr_locus (const_tree node) { #ifdef USE_MAPPED_LOCATION if (GIMPLE_STMT_P (node)) @@ -3519,7 +3519,7 @@ set_expr_locus (tree node, } const char ** -expr_filename (tree node) +expr_filename (const_tree node) { #ifdef USE_MAPPED_LOCATION if (GIMPLE_STMT_P (node)) @@ -3533,7 +3533,7 @@ expr_filename (tree node) } int * -expr_lineno (tree node) +expr_lineno (const_tree node) { #ifdef USE_MAPPED_LOCATION if (GIMPLE_STMT_P (node)) @@ -5637,7 +5637,7 @@ build_array_type (tree elt_type, tree in the innermost dimension of ARRAY. */ tree -get_inner_array_type (tree array) +get_inner_array_type (const_tree array) { tree type = TREE_TYPE (array); @@ -7803,7 +7803,7 @@ needs_to_live_in_memory (tree t) are compatible. It is assumed that the parent records are compatible. */ bool -fields_compatible_p (tree f1, tree f2) +fields_compatible_p (const_tree f1, const_tree f2) { if (!operand_equal_p (DECL_FIELD_BIT_OFFSET (f1), DECL_FIELD_BIT_OFFSET (f2), OEP_ONLY_CONST)) diff -rup orig/egcc-SVN20070727/gcc/tree.h egcc-SVN20070727/gcc/tree.h --- orig/egcc-SVN20070727/gcc/tree.h 2007-07-26 23:03:31.000000000 -0400 +++ egcc-SVN20070727/gcc/tree.h 2007-07-27 14:59:39.517607779 -0400 @@ -3830,7 +3830,7 @@ extern int tree_int_cst_sign_bit (tree); extern bool tree_expr_nonnegative_p (tree); extern bool tree_expr_nonnegative_warnv_p (tree, bool *); extern bool may_negate_without_overflow_p (tree); -extern tree get_inner_array_type (tree); +extern tree get_inner_array_type (const_tree); /* From expmed.c. Since rtl.h is included after tree.h, we can't put the prototype here. Rtl.h does declare the prototype if @@ -4597,19 +4597,19 @@ extern tree build_range_type (tree, tree extern HOST_WIDE_INT int_cst_value (const_tree); extern tree build_addr (tree, tree); -extern bool fields_compatible_p (tree, tree); +extern bool fields_compatible_p (const_tree, const_tree); extern tree find_compatible_field (tree, tree); -extern location_t expr_location (tree); +extern location_t expr_location (const_tree); extern void set_expr_location (tree, location_t); -extern bool expr_has_location (tree); +extern bool expr_has_location (const_tree); extern #ifdef USE_MAPPED_LOCATION source_location * #else source_locus #endif -expr_locus (tree); +expr_locus (const_tree); extern void set_expr_locus (tree, #ifdef USE_MAPPED_LOCATION source_location *loc @@ -4617,8 +4617,8 @@ extern void set_expr_locus (tree, source_locus loc #endif ); -extern const char **expr_filename (tree); -extern int *expr_lineno (tree); +extern const char **expr_filename (const_tree); +extern int *expr_lineno (const_tree); extern tree *tree_block (tree); extern tree *generic_tree_operand (tree, int); extern tree *generic_tree_type (tree); @@ -4652,9 +4652,9 @@ extern void print_rtl (FILE *, const_rtx /* In print-tree.c */ extern void debug_tree (tree); #ifdef BUFSIZ -extern void dump_addr (FILE*, const char *, void *); +extern void dump_addr (FILE*, const char *, const void *); extern void print_node (FILE *, const char *, tree, int); -extern void print_node_brief (FILE *, const char *, tree, int); +extern void print_node_brief (FILE *, const char *, const_tree, int); extern void indent_to (FILE *, int); #endif @@ -4695,11 +4695,11 @@ extern tree build_duplicate_type (tree); it does not necessarily fit ECF_CONST). */ #define ECF_NOVOPS 1024 -extern int flags_from_decl_or_type (tree); +extern int flags_from_decl_or_type (const_tree); extern int call_expr_flags (tree); -extern int setjmp_call_p (tree); -extern bool alloca_call_p (tree); +extern int setjmp_call_p (const_tree); +extern bool alloca_call_p (const_tree); extern bool must_pass_in_stack_var_size (enum machine_mode, tree); extern bool must_pass_in_stack_var_size_or_pad (enum machine_mode, tree);