Sorry, I forgot to remove the line '*explicit_version_p = true;' in my
previous patch.

This is an updated patch.

Thanks!

---
gcc/ChangeLog:

        * common/config/riscv/riscv-common.c
(riscv_subset_list::parsing_subset_version):
        Fix -march option parsing when `p` extension exists.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/attribute-18.c: New test.

-- 
Cheers,
Xing
diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c
index b3f5c07c819..6bbe25dba89 100644
--- a/gcc/common/config/riscv/riscv-common.c
+++ b/gcc/common/config/riscv/riscv-common.c
@@ -527,9 +527,7 @@ riscv_subset_list::parsing_subset_version (const char *ext,
 	      /* Might be beginning of `p` extension.  */
 	      if (std_ext_p)
 		{
-		  *major_version = version;
-		  *minor_version = 0;
-		  *explicit_version_p = true;
+		  get_default_version (ext, major_version, minor_version);
 		  return p;
 		}
 	      else
diff --git a/gcc/testsuite/gcc.target/riscv/attribute-18.c b/gcc/testsuite/gcc.target/riscv/attribute-18.c
new file mode 100644
index 00000000000..30a12543ed2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/attribute-18.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64imafdcp -mabi=lp64d" } */
+int foo() {}
+/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p\"" } } */

Reply via email to