Index: llvm/lib/Support/RISCVISAInfo.cpp =================================================================== --- llvm/lib/Support/RISCVISAInfo.cpp +++ llvm/lib/Support/RISCVISAInfo.cpp @@ -629,6 +629,10 @@ break; } + if (Arch.back() == '_') + return createStringError(errc::invalid_argument, + "extension name missing after separator '_'"); + // Skip rvxxx StringRef Exts = Arch.substr(5); Index: llvm/unittests/Support/RISCVISAInfoTest.cpp =================================================================== --- llvm/unittests/Support/RISCVISAInfoTest.cpp +++ llvm/unittests/Support/RISCVISAInfoTest.cpp @@ -317,16 +317,12 @@ EXPECT_EQ( toString(RISCVISAInfo::parseArchString("rv64i__m", true).takeError()), "invalid standard user-level extension '_'"); - EXPECT_EQ( - toString(RISCVISAInfo::parseArchString("rv32ezicsr_", true).takeError()), - "extension name missing after separator '_'"); - - // FIXME: Trailing underscores after single letter extensions are accepted, - // which is inconsistent. - ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv32i_", true), - Succeeded()); - ASSERT_THAT_EXPECTED(RISCVISAInfo::parseArchString("rv64im_", true), - Succeeded()); + + for (StringRef Input : + {"rv32ezicsr__zifencei", "rv32i_", "rv32izicsr_", "rv64im_"}) { + EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()), + "extension name missing after separator '_'"); + } } TEST(ParseArchString, RejectsDuplicateExtensionNames) {