Index: llvm/lib/Support/RISCVISAInfo.cpp =================================================================== --- llvm/lib/Support/RISCVISAInfo.cpp +++ llvm/lib/Support/RISCVISAInfo.cpp @@ -622,6 +622,9 @@ break; case 'g': // g = imafd + if (Arch.size() > 5 && isdigit(Arch[5])) + return createStringError(errc::invalid_argument, + "version not supported for 'g'"); StdExts = StdExts.drop_front(4); break; } Index: llvm/unittests/Support/RISCVISAInfoTest.cpp =================================================================== --- llvm/unittests/Support/RISCVISAInfoTest.cpp +++ llvm/unittests/Support/RISCVISAInfoTest.cpp @@ -397,14 +397,11 @@ "(this compiler supports 0.2)"); } -TEST(ParseArchString, AcceptsExtensionVersionForG) { - // FIXME: As there is no versioning scheme for G, arguably an error should - // be produced. - auto MaybeISAInfo = RISCVISAInfo::parseArchString("rv64g9p9", true, false); - ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded()); - RISCVISAInfo::OrderedExtensionMap Exts = (*MaybeISAInfo)->getExtensions(); - EXPECT_EQ(Exts.size(), 5UL); - EXPECT_TRUE(Exts.at("i") == (RISCVExtensionInfo{"i", 2, 0})); +TEST(ParseArchString, RejectsExtensionVersionForG) { + for (StringRef Input : {"rv32g1c", "rv64g2p0"}) { + EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()), + "version not supported for 'g'"); + } } TEST(ParseArchString, AddsImpliedExtensions) {