[flang] Support fir.boxchar in getTypeAsString (#70997)

This commit is contained in:
Valentin Clement (バレンタイン クレメン) 2023-11-01 17:41:20 -07:00 committed by GitHub
parent 373c343a77
commit 2667dbff12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -545,7 +545,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
break;
} else if (auto charTy = mlir::dyn_cast_or_null<fir::CharacterType>(ty)) {
name << 'c' << kindMap.getCharacterBitsize(charTy.getFKind());
if (charTy.getLen() != fir::CharacterType::singleton())
if (charTy.getLen() == fir::CharacterType::unknownLen())
name << "xU";
else if (charTy.getLen() != fir::CharacterType::singleton())
name << "x" << charTy.getLen();
break;
} else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(ty)) {
@ -574,6 +576,9 @@ std::string getTypeAsString(mlir::Type ty, const fir::KindMapping &kindMap,
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(ty)) {
name << "box_";
ty = boxTy.getEleTy();
} else if (auto boxcharTy = mlir::dyn_cast_or_null<fir::BoxCharType>(ty)) {
name << "boxchar_";
ty = boxcharTy.getEleTy();
} else if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(ty)) {
name << "rec_" << recTy.getName();
break;

View File

@ -313,4 +313,6 @@ TEST_F(FIRTypesTest, getTypeAsString) {
fir::getTypeAsString(
fir::LLVMPointerType::get(mlir::IntegerType::get(&context, 32)),
*kindMap));
EXPECT_EQ("boxchar_c8xU",
fir::getTypeAsString(fir::BoxCharType::get(&context, 1), *kindMap));
}