From 5ebdd53534db25401473db5f6a0ad30f41410241 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 14 Jan 2021 16:28:27 +0100 Subject: [PATCH] i386: Resolve variable shadowing in i386-options.c [PR98671] MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also change global variable pta_size to unsigned. 2021-01-14 Uroš Bizjak gcc/ PR target/98671 * config/i386/i386-options.c (ix86_valid_target_attribute_inner_p): Remove declaration and initialization of shadow variable "ret". (ix86_option_override_internal): Remove delcaration of shadow variable "i". Redeclare shadowed variable to unsigned. * common/config/i386/i386-common.c (pta_size): Redeclare to unsigned. * config/i386/i386-builtins.c (get_builtin_code_for_version): Update for redeclaration. * config/i386/i386.h (pta_size): Ditto. --- gcc/common/config/i386/i386-common.c | 2 +- gcc/config/i386/i386-builtins.c | 2 +- gcc/config/i386/i386-options.c | 6 ++---- gcc/config/i386/i386.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index 00843d4bd93..eea8af12f48 100644 --- a/gcc/common/config/i386/i386-common.c +++ b/gcc/common/config/i386/i386-common.c @@ -2051,7 +2051,7 @@ const pta processor_alias_table[] = }; /* NB: processor_alias_table stops at the "generic" entry. */ -int const pta_size = ARRAY_SIZE (processor_alias_table) - 6; +unsigned int const pta_size = ARRAY_SIZE (processor_alias_table) - 6; unsigned int const num_arch_names = ARRAY_SIZE (processor_alias_table); /* Provide valid option values for -march and -mtune options. */ diff --git a/gcc/config/i386/i386-builtins.c b/gcc/config/i386/i386-builtins.c index 5b37fc7b75e..4fcdf4b89ee 100644 --- a/gcc/config/i386/i386-builtins.c +++ b/gcc/config/i386/i386-builtins.c @@ -1888,7 +1888,7 @@ get_builtin_code_for_version (tree decl, tree *predicate_list) gcc_assert (new_target); if (new_target->arch_specified && new_target->arch > 0) - for (i = 0; i < (unsigned int) pta_size; i++) + for (i = 0; i < pta_size; i++) if (processor_alias_table[i].processor == new_target->arch) { const pta *arch_info = &processor_alias_table[i]; diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c index 4e0165ff32c..6819a042389 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -1088,8 +1088,6 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[], /* If this is a list, recurse to get the options. */ if (TREE_CODE (args) == TREE_LIST) { - bool ret = true; - for (; args; args = TREE_CHAIN (args)) if (TREE_VALUE (args) && !ix86_valid_target_attribute_inner_p (fndecl, TREE_VALUE (args), @@ -1782,7 +1780,7 @@ ix86_option_override_internal (bool main_args_p, struct gcc_options *opts, struct gcc_options *opts_set) { - int i; + unsigned int i; unsigned HOST_WIDE_INT ix86_arch_mask; const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL); @@ -2852,7 +2850,7 @@ ix86_option_override_internal (bool main_args_p, { char *p = ASTRDUP (opts->x_ix86_recip_name); char *q; - unsigned int mask, i; + unsigned int mask; bool invert; while ((q = strtok (p, ",")) != NULL) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index f032746d222..272b1957b47 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2562,7 +2562,7 @@ public: }; extern const pta processor_alias_table[]; -extern int const pta_size; +extern unsigned int const pta_size; extern unsigned int const num_arch_names; #endif -- 2.30.2