diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c index eea8af12f48..b89183b830e 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. */ -unsigned int const pta_size = ARRAY_SIZE (processor_alias_table) - 6; +unsigned int const pta_size = ARRAY_SIZE (processor_alias_table) - 7; 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-options.c b/gcc/config/i386/i386-options.c index b653527d266..88d5e717f26 100644 --- a/gcc/config/i386/i386-options.c +++ b/gcc/config/i386/i386-options.c @@ -2042,6 +2042,9 @@ ix86_option_override_internal (bool main_args_p, sorry ("%i-bit mode not compiled in", (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32); + /* Last processor_alias_table must point to "generic" entry. */ + gcc_checking_assert (strcmp (processor_alias_table[pta_size - 1].name, + "generic") == 0); for (i = 0; i < pta_size; i++) if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name)) { diff --git a/gcc/testsuite/gcc.target/i386/pr99753.c b/gcc/testsuite/gcc.target/i386/pr99753.c new file mode 100644 index 00000000000..3def1fd7481 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr99753.c @@ -0,0 +1,5 @@ +/* PR target/99753 */ + +/* { dg-do compile } */ +/* { dg-options "-march=amd -m32" } */ +/* { dg-error "bad value .'amd'. for '-march=' switch" "" { target *-*-* } 0 } */