From 285cf766c1309edd7e61bf0dc45754af987d1b26 Mon Sep 17 00:00:00 2001 From: Maxim Blinov Date: Wed, 31 Jul 2019 21:36:41 +0000 Subject: [PATCH] RISC-V: Raise error on unexpected ISA string at end. 2019-07-31 Maxim Blinov gcc/ * common/config/riscv/riscv-common.c: Check -march string ends with null. gcc/testsuite/ * gcc.target/riscv/attribute-10.c: New test. From-SVN: r273951 --- gcc/ChangeLog | 5 +++++ gcc/common/config/riscv/riscv-common.c | 7 +++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/riscv/attribute-10.c | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/attribute-10.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7d8339c9acfa..ec13629349fe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-31 Maxim Blinov + + * common/config/riscv/riscv-common.c: Check -march string ends + with null. + 2019-07-31 Alexander Monakov * ipa-devirt.c (type_warning_cmp): Make static. diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c index eeb75717db04..a16d6c5b4486 100644 --- a/gcc/common/config/riscv/riscv-common.c +++ b/gcc/common/config/riscv/riscv-common.c @@ -513,6 +513,13 @@ riscv_subset_list::parse (const char *arch, location_t loc) if (p == NULL) goto fail; + if (*p != '\0') + { + error_at (loc, "%<-march=%s%>: unexpected ISA string at end: %qs", + arch, p); + goto fail; + } + return subset_list; fail: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f490292d5346..99f6b22f86c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-31 Maxim Blinov + + * gcc.target/riscv/attribute-10.c: New test. + 2019-07-31 Richard Biener PR tree-optimization/91280 diff --git a/gcc/testsuite/gcc.target/riscv/attribute-10.c b/gcc/testsuite/gcc.target/riscv/attribute-10.c new file mode 100644 index 000000000000..dd817879a675 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/attribute-10.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32im_s_sx_unexpectedstring -mabi=ilp32" } */ +int foo() +{ +} +/* { dg-error "unexpected ISA string at end:" "" { target { "riscv*-*-*" } } 0 } */ -- 2.43.5