From mboxrd@z Thu Jan 1 00:00:00 1970 From: "John David Anglin" To: dave@hiauly1.hia.nrc.ca (John David Anglin) Cc: gcc-patches@gcc.gnu.org Subject: Re: Enum related fixes for gcc build with native cc on vax ultrix Date: Thu, 01 Mar 2001 17:31:00 -0000 Message-id: <200103020131.UAA00776@hiauly1.hia.nrc.ca> References: X-SW-Source: 2001-03/msg00058.html > The patch has been bootstrapped under vax ultrix, and a complete bootstrap > check has been done under i686 linux. > > Please review. Some of this is now complete. I enclose what remains to be OK'd. In my original post, I inadvertantly omitted the required changes to toplev.c. Dave -- J. David Anglin dave.anglin@nrc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6605) 2001-02-19 John David Anglin * print-rtl.c (print_rtx): Cast enums to int for comparison. * c-decl.c (grokdeclarator): Cast enums to int for comparison and shifts. * c-format.c (C_STD_VER): Cast to int for comparisons. (check_function_format): Cast various enums to int for &. (maybe_read_dollar_number): Likewise. (check_format_info): Likewise. (check_format_info_main): Likewise. * function.c (purge_addressof_1): Revise to avoid using &= with enum result. * expr.c (emit_move_insn_1): Cast enums to unsigned int for comparison. (safe_from_p): Likewise. * varasm.c (const_hash): Cast enum to int for %. * emit-rtl.c (init_emit_once): Use int loop variable to work around pcc enum problems with < and ++ operators. * regclass.c (init_reg_sets_1): Cast enums for comparison. (choose_hard_reg_mode): Use unsigned int to iterate over CCmodes. (regclass_init): Change enum class to int to iterate over reg_classes. * genrecog.c (merge_trees): Cast enums for comparison. * rtl.h (GET_CODE): Cast to enum rtx_code. (PUT_CODE): Cast to ENUM_BITFIELD(rtx_code). (GET_MODE): Cast to enum machine_mode. (PUT_MODE): Cast to ENUM_BITFIELD(machine_mode). (GET_NOTE_INSN_NAME): Cast enum to int. * tree.h (TREE_CODE): Cast to enum tree_code. (TREE_SET_CODE): Cast VALUE to ENUM_BITFIELD(tree_code). * simplify-rtx.c (hash_rtx): Cast enums to unsigned unt. * timevar.c (timevar_print): Change loop variable id from enum to unsigned int. * fixinc/fixincl.c (VLEVEL): Cast enums in comparison to unsigned int. * fixinc/fixlib.h (bool_t): Add identifier `boolean' in typedef. * fixinc/server.c (read_pipe_timeout): Use enum boolean instead of bool_t in declaration because pcc can't combine volatile with typedef types. * config/i386/i386.md: Use PUT_MODE for mode assignment. * toplev.c (compile_file): Cast enum DFI to int. (decode_d_option): Likewise. --- print-rtl.c.orig Fri Jan 5 18:30:02 2001 +++ print-rtl.c Mon Feb 19 12:32:23 2001 @@ -364,8 +364,8 @@ /* Print NOTE_INSN names rather than integer codes. */ case 'n': - if (XINT (in_rtx, i) >= NOTE_INSN_BIAS - && XINT (in_rtx, i) < NOTE_INSN_MAX) + if (XINT (in_rtx, i) >= (int) NOTE_INSN_BIAS + && XINT (in_rtx, i) < (int) NOTE_INSN_MAX) fprintf (outfile, " %s", GET_NOTE_INSN_NAME (XINT (in_rtx, i))); else fprintf (outfile, " %d", XINT (in_rtx, i)); --- c-decl.c.orig Fri Feb 16 17:17:22 2001 +++ c-decl.c Mon Feb 19 12:30:57 2001 @@ -3915,9 +3915,9 @@ if (TREE_CODE (id) == IDENTIFIER_NODE && C_IS_RESERVED_WORD (id)) { enum rid i = C_RID_CODE (id); - if (i <= RID_LAST_MODIFIER) + if ((int) i <= (int) RID_LAST_MODIFIER) { - if (i == RID_LONG && specbits & (1<first_arg_num == 0 - && (format_types[info->format_type].flags & FMT_FLAG_ARG_CONVERT)) + && (format_types[info->format_type].flags + & (int) FMT_FLAG_ARG_CONVERT)) { function_format_info *info2; for (info2 = function_format_list; info2; info2 = info2->next) @@ -1298,7 +1299,7 @@ nalloc - dollar_arguments_alloc); dollar_arguments_alloc = nalloc; } - if (!(fki->flags & FMT_FLAG_DOLLAR_MULTIPLE) + if (!(fki->flags & (int) FMT_FLAG_DOLLAR_MULTIPLE) && dollar_arguments_used[argnum - 1] == 1) { dollar_arguments_used[argnum - 1] = 2; @@ -1434,7 +1435,7 @@ /* Functions taking a va_list normally pass a non-literal format string. These functions typically are declared with first_arg_num == 0, so avoid warning in those cases. */ - if (!(format_types[info->format_type].flags & FMT_FLAG_ARG_CONVERT)) + if (!(format_types[info->format_type].flags & (int) FMT_FLAG_ARG_CONVERT)) { /* For strftime-like formats, warn for not checking the format string; but there are no arguments to check. */ @@ -1746,7 +1747,7 @@ } flag_chars[0] = 0; - if ((fki->flags & FMT_FLAG_USE_DOLLAR) && has_operand_number != 0) + if ((fki->flags & (int) FMT_FLAG_USE_DOLLAR) && has_operand_number != 0) { /* Possibly read a $ operand number at the start of the format. If one was previously used, one is required here. If one @@ -1867,7 +1868,7 @@ ++format_chars; } if (found_width && !non_zero_width_char && - (fki->flags & FMT_FLAG_ZERO_WIDTH_BAD)) + (fki->flags & (int) FMT_FLAG_ZERO_WIDTH_BAD)) status_warning (status, "zero width in %s format", fki->name); if (found_width) @@ -1954,7 +1955,7 @@ } else { - if (!(fki->flags & FMT_FLAG_EMPTY_PREC_OK) + if (!(fki->flags & (int) FMT_FLAG_EMPTY_PREC_OK) && !ISDIGIT (*format_chars)) status_warning (status, "empty precision in %s format", fki->name); @@ -2025,7 +2026,7 @@ } /* Handle the scanf allocation kludge. */ - if (fki->flags & FMT_FLAG_SCANF_A_KLUDGE) + if (fki->flags & (int) FMT_FLAG_SCANF_A_KLUDGE) { if (*format_chars == 'a' && !flag_isoc99) { @@ -2043,7 +2044,8 @@ format_char = *format_chars; if (format_char == 0 - || (!(fki->flags & FMT_FLAG_FANCY_PERCENT_OK) && format_char == '%')) + || (!(fki->flags & (int) FMT_FLAG_FANCY_PERCENT_OK) + && format_char == '%')) { status_warning (status, "conversion lacks type at end of format"); continue; @@ -2109,7 +2111,7 @@ flag_chars[i - d] = 0; } - if ((fki->flags & FMT_FLAG_SCANF_A_KLUDGE) + if ((fki->flags & (int) FMT_FLAG_SCANF_A_KLUDGE) && strchr (flag_chars, 'a') != 0) aflag = 1; @@ -2190,7 +2192,7 @@ wanted_type = 0; wanted_type_name = 0; - if (fki->flags & FMT_FLAG_ARG_CONVERT) + if (fki->flags & (int) FMT_FLAG_ARG_CONVERT) { wanted_type = (fci->types[length_chars_val].type ? *fci->types[length_chars_val].type : 0); --- function.c.orig Fri Feb 16 17:17:29 2001 +++ function.c Wed Feb 28 16:14:35 2001 @@ -2996,9 +2996,10 @@ memory. */ if (code == SET) { - result = purge_addressof_1 (&SET_DEST (x), insn, force, 1, ht); - result &= purge_addressof_1 (&SET_SRC (x), insn, force, 0, ht); - return result; + if (purge_addressof_1 (&SET_DEST (x), insn, force, 1, ht) == true + && purge_addressof_1 (&SET_SRC (x), insn, force, 0, ht) == true) + return true; + return false; } else if (code == ADDRESSOF && GET_CODE (XEXP (x, 0)) == MEM) @@ -3230,9 +3231,10 @@ } else if (code == SET) { - result = purge_addressof_1 (&SET_DEST (x), insn, force, 1, ht); - result &= purge_addressof_1 (&SET_SRC (x), insn, force, 0, ht); - return result; + if (purge_addressof_1 (&SET_DEST (x), insn, force, 1, ht) == true + && purge_addressof_1 (&SET_SRC (x), insn, force, 0, ht) == true) + return true; + return false; } /* Scan all subexpressions. */ @@ -3240,10 +3242,19 @@ for (i = 0; i < GET_RTX_LENGTH (code); i++, fmt++) { if (*fmt == 'e') - result &= purge_addressof_1 (&XEXP (x, i), insn, force, 0, ht); + { + if (result == true + && purge_addressof_1 (&XEXP (x, i), insn, force, 0, ht) == false) + result = false; + } else if (*fmt == 'E') - for (j = 0; j < XVECLEN (x, i); j++) - result &= purge_addressof_1 (&XVECEXP (x, i, j), insn, force, 0, ht); + { + for (j = 0; j < XVECLEN (x, i); j++) + if (result == true + && purge_addressof_1 (&XVECEXP (x, i, j), insn, force, 0, ht) + == false) + result = false; + } } return result; --- expr.c.orig Sun Feb 4 17:43:59 2001 +++ expr.c Wed Feb 28 16:54:19 2001 @@ -2766,7 +2766,7 @@ enum mode_class class = GET_MODE_CLASS (mode); unsigned int i; - if (mode >= MAX_MACHINE_MODE) + if ((unsigned int) mode >= (unsigned int) MAX_MACHINE_MODE) abort (); if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing) @@ -5766,7 +5766,8 @@ /* If this is a language-specific tree code, it may require special handling. */ - if (TREE_CODE (exp) >= LAST_AND_UNUSED_TREE_CODE + if ((unsigned int) TREE_CODE (exp) + >= (unsigned int) LAST_AND_UNUSED_TREE_CODE && lang_safe_from_p && !(*lang_safe_from_p) (x, exp)) return 0; --- varasm.c.orig Sun Feb 4 03:29:46 2001 +++ varasm.c Mon Feb 19 22:17:35 2001 @@ -2431,7 +2431,7 @@ default: /* A language specific constant. Just hash the code. */ - return code % MAX_HASH_TABLE; + return (int) code % MAX_HASH_TABLE; } /* Compute hashing function */ --- emit-rtl.c.orig Sun Feb 4 17:43:58 2001 +++ emit-rtl.c Tue Feb 20 00:09:00 2001 @@ -4139,9 +4139,9 @@ const_tiny_rtx[i][(int) mode] = GEN_INT (i); } - for (mode = CCmode; mode < MAX_MACHINE_MODE; ++mode) - if (GET_MODE_CLASS (mode) == MODE_CC) - const_tiny_rtx[0][(int) mode] = const0_rtx; + for (i = (int) CCmode; i < (int) MAX_MACHINE_MODE; ++i) + if (GET_MODE_CLASS ((enum machine_mode) i) == MODE_CC) + const_tiny_rtx[0][i] = const0_rtx; const_tiny_rtx[0][(int) BImode] = const0_rtx; if (STORE_FLAG_VALUE == 1) --- regclass.c.orig Mon Feb 19 16:49:40 2001 +++ regclass.c Tue Feb 27 16:11:58 2001 @@ -430,7 +430,7 @@ } memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode)); memset (allocatable_regs_of_mode, 0, sizeof (allocatable_regs_of_mode)); - for (m = 0; m < MAX_MACHINE_MODE; m++) + for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++) for (i = 0; i < N_REG_CLASSES; i++) if (CLASS_MAX_NREGS (i, m) <= reg_class_size[i]) for (j = 0; j < FIRST_PSEUDO_REGISTER; j++) @@ -445,7 +445,7 @@ /* Initialize the move cost table. Find every subset of each class and take the maximum cost of moving any subset to any other. */ - for (m = 0; m < MAX_MACHINE_MODE; m++) + for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++) if (allocatable_regs_of_mode [m]) { for (i = 0; i < N_REG_CLASSES; i++) @@ -631,6 +631,7 @@ unsigned int regno ATTRIBUTE_UNUSED; unsigned int nregs; { + unsigned int /* enum machine_mode */ m; enum machine_mode found_mode = VOIDmode, mode; /* We first look for the largest integer mode that can be validly @@ -658,10 +659,13 @@ return found_mode; /* Iterate over all of the CCmodes. */ - for (mode = CCmode; mode < NUM_MACHINE_MODES; ++mode) - if (HARD_REGNO_NREGS (regno, mode) == nregs - && HARD_REGNO_MODE_OK (regno, mode)) - return mode; + for (m = (unsigned int) CCmode; m < (unsigned int) NUM_MACHINE_MODES; ++m) + { + mode = (enum machine_mode) m; + if (HARD_REGNO_NREGS (regno, mode) == nregs + && HARD_REGNO_MODE_OK (regno, mode)) + return mode; + } /* We can't find a mode valid for this register. */ return VOIDmode; @@ -859,22 +863,23 @@ int i; for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) { - enum reg_class class; + int /* enum reg_class */ class; if (REG_N_REFS (i)) { fprintf (dump, " Register %i costs:", i); - for (class = 0; class < N_REG_CLASSES; class++) - if (contains_reg_of_mode [class][PSEUDO_REGNO_MODE (i)] + for (class = 0; class < (int) N_REG_CLASSES; class++) + if (contains_reg_of_mode [(enum reg_class) class][PSEUDO_REGNO_MODE (i)] #ifdef FORBIDDEN_INC_DEC_CLASSES - && (!in_inc_dec[i] || !forbidden_inc_dec_class[class]) + && (!in_inc_dec[i] + || !forbidden_inc_dec_class[(enum reg_class) class]) #endif #ifdef CLASS_CANNOT_CHANGE_MODE && (!REGNO_REG_SET_P (reg_changes_mode, i) - || class_can_change_mode [class]) + || class_can_change_mode [(enum reg_class) class]) #endif ) - fprintf (dump, " %s:%i", reg_class_names[(int) class], - costs[i].cost[class]); + fprintf (dump, " %s:%i", reg_class_names[class], + costs[i].cost[(enum reg_class) class]); fprintf (dump, " MEM:%i\n", costs[i].mem_cost); } } --- genrecog.c.orig Sun Jan 14 15:35:06 2001 +++ genrecog.c Tue Feb 20 14:34:17 2001 @@ -1432,7 +1432,7 @@ how expensive/important the test is. Given that the tests are also ordered within the list, examining the first is sufficient. */ - if (add->tests->type < old->tests->type) + if ((int) add->tests->type < (int) old->tests->type) insert_before = old; } --- rtl.h.orig Sun Feb 18 23:52:53 2001 +++ rtl.h Tue Feb 20 15:38:54 2001 @@ -184,11 +184,11 @@ /* Define macros to access the `code' field of the rtx. */ -#define GET_CODE(RTX) ((RTX)->code) -#define PUT_CODE(RTX, CODE) ((RTX)->code = (CODE)) +#define GET_CODE(RTX) ((enum rtx_code) (RTX)->code) +#define PUT_CODE(RTX, CODE) ((RTX)->code = (ENUM_BITFIELD(rtx_code)) (CODE)) -#define GET_MODE(RTX) ((RTX)->mode) -#define PUT_MODE(RTX, MODE) ((RTX)->mode = (MODE)) +#define GET_MODE(RTX) ((enum machine_mode) (RTX)->mode) +#define PUT_MODE(RTX, MODE) ((RTX)->mode = (ENUM_BITFIELD(machine_mode)) (MODE)) #define RTX_INTEGRATED_P(RTX) ((RTX)->integrated) #define RTX_UNCHANGING_P(RTX) ((RTX)->unchanging) @@ -702,7 +702,7 @@ extern const char * const note_insn_name[NOTE_INSN_MAX - NOTE_INSN_BIAS]; #define GET_NOTE_INSN_NAME(NOTE_CODE) \ - (note_insn_name[(NOTE_CODE) - NOTE_INSN_BIAS]) + (note_insn_name[(NOTE_CODE) - (int) NOTE_INSN_BIAS]) /* The name of a label, in case it corresponds to an explicit label in the input source code. */ --- tree.h.orig Fri Feb 16 17:17:38 2001 +++ tree.h Wed Feb 21 10:53:19 2001 @@ -274,7 +274,8 @@ /* The tree-code says what kind of node it is. Codes are defined in tree.def. */ #define TREE_CODE(NODE) ((enum tree_code) (NODE)->common.code) -#define TREE_SET_CODE(NODE, VALUE) ((NODE)->common.code = (int) (VALUE)) +#define TREE_SET_CODE(NODE, VALUE) \ +((NODE)->common.code = (ENUM_BITFIELD(tree_code)) (VALUE)) /* When checking is enabled, errors will be generated if a tree node is accessed incorrectly. The macros abort with a fatal error. */ --- simplify-rtx.c.orig Tue Feb 6 07:39:15 2001 +++ simplify-rtx.c Wed Feb 21 10:49:42 2001 @@ -2640,7 +2640,7 @@ case CONST_INT: hash += ((unsigned) CONST_INT << 7) + (unsigned) mode + INTVAL (x); - return hash ? hash : CONST_INT; + return hash ? hash : (unsigned int) CONST_INT; case CONST_DOUBLE: /* This is like the general case, except that it only counts @@ -2652,18 +2652,18 @@ else hash += ((unsigned) CONST_DOUBLE_LOW (x) + (unsigned) CONST_DOUBLE_HIGH (x)); - return hash ? hash : CONST_DOUBLE; + return hash ? hash : (unsigned int) CONST_DOUBLE; /* Assume there is only one rtx object for any given label. */ case LABEL_REF: hash += ((unsigned) LABEL_REF << 7) + (unsigned long) XEXP (x, 0); - return hash ? hash : LABEL_REF; + return hash ? hash : (unsigned int) LABEL_REF; case SYMBOL_REF: hash += ((unsigned) SYMBOL_REF << 7) + (unsigned long) XSTR (x, 0); - return hash ? hash : SYMBOL_REF; + return hash ? hash : (unsigned int) SYMBOL_REF; case PRE_DEC: case PRE_INC: @@ -2737,7 +2737,7 @@ abort (); } - return hash ? hash : 1 + GET_CODE (x); + return hash ? hash : 1 + (unsigned int) GET_CODE (x); } /* Create a new value structure for VALUE and initialize it. The mode of the --- timevar.c.orig Wed Sep 6 03:02:40 2000 +++ timevar.c Wed Feb 21 14:01:41 2001 @@ -401,7 +401,7 @@ { /* Only print stuff if we have some sort of time information. */ #if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME) - timevar_id_t id; + unsigned int /* timevar_id_t */ id; struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed; struct timevar_time_def now; @@ -426,13 +426,13 @@ start_time = now; fprintf (fp, _("\nExecution times (seconds)\n")); - for (id = 0; id < TIMEVAR_LAST; ++id) + for (id = 0; id < (unsigned int) TIMEVAR_LAST; ++id) { - struct timevar_def *tv = &timevars[id]; + struct timevar_def *tv = &timevars[(timevar_id_t) id]; /* Don't print the total execution time here; that goes at the end. */ - if (id == TV_TOTAL) + if ((timevar_id_t) id == TV_TOTAL) continue; /* Don't print timing variables that were never used. */ --- fixinc/fixincl.c.orig Tue Feb 6 17:17:08 2001 +++ fixinc/fixincl.c Wed Feb 21 15:47:24 2001 @@ -67,7 +67,7 @@ te_verbose verbose_level = VERB_PROGRESS; int have_tty = 0; -#define VLEVEL(l) (verbose_level >= l) +#define VLEVEL(l) ((unsigned int) verbose_level >= (unsigned int) l) #define NOT_SILENT VLEVEL(VERB_FIXES) pid_t process_chain_head = (pid_t) -1; --- fixinc/fixlib.h.orig Wed Dec 13 15:07:46 2000 +++ fixinc/fixlib.h Wed Feb 21 17:54:05 2001 @@ -88,7 +88,7 @@ #define IGNORE_ARG(a) ((void)(a)) -typedef enum +typedef enum boolean { BOOL_FALSE, BOOL_TRUE } t_bool; --- fixinc/server.c.orig Wed Feb 21 17:54:28 2001 +++ fixinc/server.c Wed Feb 21 17:55:11 2001 @@ -57,7 +57,7 @@ # define volatile #endif -STATIC volatile t_bool read_pipe_timeout; +STATIC volatile enum boolean read_pipe_timeout; STATIC pid_t server_master_pid = NOPROCESS; tSCC* def_args[] = --- config/i386/i386.md.orig Mon Feb 26 19:43:06 2001 +++ config/i386/i386.md Tue Feb 27 18:46:45 2001 @@ -11784,7 +11784,7 @@ operands[1] = gen_lowpart (SImode, operands[1]); if (GET_CODE (operands[3]) != ASHIFT) operands[2] = gen_lowpart (SImode, operands[2]); - GET_MODE (operands[3]) = SImode;") + PUT_MODE (operands[3], SImode);") (define_split [(set (reg 17) --- toplev.c.orig Wed Feb 21 18:19:38 2001 +++ toplev.c Thu Mar 1 17:20:43 2001 @@ -2520,7 +2520,7 @@ { int i; - for (i = 0; i < DFI_MAX; ++i) + for (i = 0; i < (int) DFI_MAX; ++i) if (dump_file[i].initialized && dump_file[i].graph_dump_p) { char seq[16]; @@ -4014,7 +4014,7 @@ switch (c = *arg++) { case 'a': - for (i = 0; i < DFI_MAX; ++i) + for (i = 0; i < (int) DFI_MAX; ++i) dump_file[i].enabled = 1; break; case 'A': @@ -4045,7 +4045,7 @@ default: matched = 0; - for (i = 0; i < DFI_MAX; ++i) + for (i = 0; i < (int) DFI_MAX; ++i) if (c == dump_file[i].debug_switch) { dump_file[i].enabled = 1;