RISC-V: Check multiletter extension has more than 1 letter
authorKito Cheng <kito.cheng@sifive.com>
Thu, 20 Aug 2020 09:19:41 +0000 (17:19 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 2 Nov 2020 09:09:00 +0000 (17:09 +0800)
gcc/ChangeLog:

* common/config/riscv/riscv-common.c
(riscv_subset_list::parse_multiletter_ext): Checking multiletter
extension has more than 1 letter.

gcc/testsuite/ChangeLog

* gcc.target/riscv/arch-7.c: New.
* gcc.target/riscv/attribute-10.c: Update test arch string.

gcc/common/config/riscv/riscv-common.c
gcc/testsuite/gcc.target/riscv/arch-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/attribute-10.c

index b84503a7742990266275e5ba3f6b0888b4eadba8..84695a6ed1b8817b592a46913ecaf720d2a5fbc2 100644 (file)
@@ -524,6 +524,14 @@ riscv_subset_list::parse_multiletter_ext (const char *p,
 
       *q = '\0';
 
+      if (strlen (subset) == 1)
+       {
+         error_at (m_loc, "%<-march=%s%>: name of %s must be more than 1 letter",
+                   m_arch, ext_type_str);
+         free (subset);
+         return NULL;
+       }
+
       add (subset, major_version, minor_version, explicit_version_p);
       free (subset);
       p += end_of_version - subset;
diff --git a/gcc/testsuite/gcc.target/riscv/arch-7.c b/gcc/testsuite/gcc.target/riscv/arch-7.c
new file mode 100644 (file)
index 0000000..74ab248
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32i -march=rv32im_s -mabi=ilp32" } */
+int foo()
+{
+}
+/* { dg-error ".'-march=rv32im_s': name of supervisor extension must be more than 1 letter" "" { target *-*-* } 0 } */
index a874a6234dce343466db3d568e221d4b237fe97d..26fdd08b26dd8dd10f2294090bc42772bb0fba91 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -march=rv32i -march=rv32im_s_sx_unexpectedstring -mabi=ilp32" } */
+/* { dg-options "-O2 -march=rv32i -march=rv32im_sx_unexpectedstring -mabi=ilp32" } */
 int foo()
 {
 }