diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 526dbb7603b..5111626157b 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -1017,15 +1017,24 @@ riscv_subset_list::parse_std_ext (const char *p) std_ext = *p; /* Checking canonical order. */ + const char *prior_std_exts = std_exts; + while (*std_exts && std_ext != *std_exts) std_exts++; subset[0] = std_ext; if (std_ext != *std_exts && standard_extensions_p (subset)) - error_at (m_loc, - "%<-march=%s%>: ISA string is not in canonical order. " - "%<%c%>", - m_arch, *p); + { + error_at (m_loc, + "%<-march=%s%>: ISA string is not in canonical order. " + "%<%c%>", + m_arch, *p); + /* Extension ordering is invalid. Ignore this extension and keep + searching for other issues with remaining extensions. */ + std_exts = prior_std_exts; + p++; + continue; + } std_exts++; diff --git a/gcc/testsuite/gcc.target/riscv/arch-27.c b/gcc/testsuite/gcc.target/riscv/arch-27.c new file mode 100644 index 00000000000..70143b2156f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-27.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64ge -mabi=lp64d" } */ +int foo() +{ +} + +/* { dg-error "ISA string is not in canonical order. 'e'" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/riscv/arch-28.c b/gcc/testsuite/gcc.target/riscv/arch-28.c new file mode 100644 index 00000000000..934399a7b3a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-28.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64imaefcv -mabi=lp64d" } */ +int foo() +{ +} + +/* { dg-error "ISA string is not in canonical order. 'e'" "" { target *-*-* } 0 } */