forked from OSchip/llvm-project
[flang] Do not emit a prefix for a default-kind character constant in AsFortran
Original-commit: flang-compiler/f18@4a3db55727 Reviewed-on: https://github.com/flang-compiler/f18/pull/1078
This commit is contained in:
parent
d2c87e0b36
commit
f4faeefe3d
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
namespace Fortran::evaluate {
|
namespace Fortran::evaluate {
|
||||||
|
|
||||||
extern bool formatForPGF90;
|
|
||||||
|
|
||||||
template<typename A>
|
template<typename A>
|
||||||
auto operator<<(std::ostream &o, const A &x) -> decltype(x.AsFortran(o)) {
|
auto operator<<(std::ostream &o, const A &x) -> decltype(x.AsFortran(o)) {
|
||||||
return x.AsFortran(o);
|
return x.AsFortran(o);
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
namespace Fortran::evaluate {
|
namespace Fortran::evaluate {
|
||||||
|
|
||||||
bool formatForPGF90{false};
|
|
||||||
|
|
||||||
static void ShapeAsFortran(std::ostream &o, const ConstantSubscripts &shape) {
|
static void ShapeAsFortran(std::ostream &o, const ConstantSubscripts &shape) {
|
||||||
if (GetRank(shape) > 1) {
|
if (GetRank(shape) > 1) {
|
||||||
o << ",shape=";
|
o << ",shape=";
|
||||||
|
@ -87,7 +85,7 @@ std::ostream &Constant<Type<TypeCategory::Character, KIND>>::AsFortran(
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
o << ',';
|
o << ',';
|
||||||
}
|
}
|
||||||
if (Result::kind != 1 || !formatForPGF90) {
|
if (Result::kind != 1) {
|
||||||
o << Result::kind << '_';
|
o << Result::kind << '_';
|
||||||
}
|
}
|
||||||
o << parser::QuoteCharacterLiteral(value);
|
o << parser::QuoteCharacterLiteral(value);
|
||||||
|
|
|
@ -22,16 +22,16 @@ end
|
||||||
|
|
||||||
!Expect: m.mod
|
!Expect: m.mod
|
||||||
!module m
|
!module m
|
||||||
! character(2_4,1),parameter::prefix=1_"c_"
|
! character(2_4,1),parameter::prefix="c_"
|
||||||
! integer(4),bind(c, name=1_"c_a")::a
|
! integer(4),bind(c, name="c_a")::a
|
||||||
! procedure(sub),bind(c, name=1_"c_b"),pointer::b
|
! procedure(sub),bind(c, name="c_b"),pointer::b
|
||||||
! type,bind(c)::t
|
! type,bind(c)::t
|
||||||
! real(4)::c
|
! real(4)::c
|
||||||
! end type
|
! end type
|
||||||
! procedure(real(4)),bind(c, name=1_"dd")::d
|
! procedure(real(4)),bind(c, name="dd")::d
|
||||||
! procedure(real(4)),bind(c, name=1_"ee")::e
|
! procedure(real(4)),bind(c, name="ee")::e
|
||||||
! procedure(real(4)),bind(c, name=1_"ff")::f
|
! procedure(real(4)),bind(c, name="ff")::f
|
||||||
!contains
|
!contains
|
||||||
! subroutine sub() bind(c, name=1_"sub")
|
! subroutine sub() bind(c, name="sub")
|
||||||
! end
|
! end
|
||||||
!end
|
!end
|
||||||
|
|
|
@ -26,7 +26,7 @@ end
|
||||||
! integer(8),parameter::i=2_8
|
! integer(8),parameter::i=2_8
|
||||||
! real(4)::r
|
! real(4)::r
|
||||||
! character(10_4,1)::c
|
! character(10_4,1)::c
|
||||||
! character(10_4,1),parameter::c2=1_"qwer "
|
! character(10_4,1),parameter::c2="qwer "
|
||||||
! complex(8),parameter::z=(1._8,2._8)
|
! complex(8),parameter::z=(1._8,2._8)
|
||||||
! complex(8),parameter::zn=(-1._8,2._8)
|
! complex(8),parameter::zn=(-1._8,2._8)
|
||||||
! type::t
|
! type::t
|
||||||
|
|
|
@ -30,6 +30,6 @@ end
|
||||||
! bind(c)::/cb2/
|
! bind(c)::/cb2/
|
||||||
! common//t,w,u,v
|
! common//t,w,u,v
|
||||||
! common/cb/x,y,z
|
! common/cb/x,y,z
|
||||||
! bind(c, name=1_"CB")::/cb/
|
! bind(c, name="CB")::/cb/
|
||||||
! common/b/cb
|
! common/b/cb
|
||||||
!end
|
!end
|
||||||
|
|
|
@ -18,6 +18,6 @@ end module m
|
||||||
!character(1_4,int(k,kind=8))::a
|
!character(1_4,int(k,kind=8))::a
|
||||||
!character(3_4,int(k,kind=8))::b
|
!character(3_4,int(k,kind=8))::b
|
||||||
!end type
|
!end type
|
||||||
!type(t(k=1_4)),parameter::p=t(k=1_4)(a=1_"x",b=1_"xx ")
|
!type(t(k=1_4)),parameter::p=t(k=1_4)(a="x",b="xx ")
|
||||||
!character(2_4,1),parameter::c2(1_8:3_8)=[CHARACTER(KIND=1,LEN=2)::1_"x ",1_"xx",1_"xx"]
|
!character(2_4,1),parameter::c2(1_8:3_8)=[CHARACTER(KIND=1,LEN=2)::"x ","xx","xx"]
|
||||||
!end
|
!end
|
||||||
|
|
|
@ -16,7 +16,7 @@ end module m
|
||||||
!Expect: m.mod
|
!Expect: m.mod
|
||||||
!module m
|
!module m
|
||||||
!character(*,4),parameter::c4=4_"Hi! \344\275\240\345\245\275!"
|
!character(*,4),parameter::c4=4_"Hi! \344\275\240\345\245\275!"
|
||||||
!character(*,1),parameter::c1=1_"Hi! \344\275\240\345\245\275!"
|
!character(*,1),parameter::c1="Hi! \344\275\240\345\245\275!"
|
||||||
!character(*,4),parameter::c4a(1_8:*)=[CHARACTER(KIND=4,LEN=1)::4_"\344\270\200",4_"\344\272\214",4_"\344\270\211",4_"\345\233\233",4_"\344\272\224"]
|
!character(*,4),parameter::c4a(1_8:*)=[CHARACTER(KIND=4,LEN=1)::4_"\344\270\200",4_"\344\272\214",4_"\344\270\211",4_"\345\233\233",4_"\344\272\224"]
|
||||||
!integer(4),parameter::lc4=7_4
|
!integer(4),parameter::lc4=7_4
|
||||||
!intrinsic::len
|
!intrinsic::len
|
||||||
|
|
|
@ -75,7 +75,7 @@ end
|
||||||
|
|
||||||
!Expect: m4a.mod
|
!Expect: m4a.mod
|
||||||
!module m4a
|
!module m4a
|
||||||
! character(1_4,1),parameter::a=1_"\001"
|
! character(1_4,1),parameter::a="\001"
|
||||||
! intrinsic::achar
|
! intrinsic::achar
|
||||||
!end
|
!end
|
||||||
|
|
||||||
|
@ -83,6 +83,6 @@ end
|
||||||
!module m4b
|
!module m4b
|
||||||
! use m4a,only:a
|
! use m4a,only:a
|
||||||
! use m4a,only:achar
|
! use m4a,only:achar
|
||||||
! character(1_4,1),parameter::b=1_"\001"
|
! character(1_4,1),parameter::b="\001"
|
||||||
!end
|
!end
|
||||||
|
|
||||||
|
|
|
@ -333,13 +333,11 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
|
||||||
{
|
{
|
||||||
std::ofstream tmpSource;
|
std::ofstream tmpSource;
|
||||||
tmpSource.open(tmpSourcePath);
|
tmpSource.open(tmpSourcePath);
|
||||||
Fortran::evaluate::formatForPGF90 = true;
|
|
||||||
Unparse(tmpSource, parseTree, driver.encoding, true /*capitalize*/,
|
Unparse(tmpSource, parseTree, driver.encoding, true /*capitalize*/,
|
||||||
options.features.IsEnabled(
|
options.features.IsEnabled(
|
||||||
Fortran::common::LanguageFeature::BackslashEscapes),
|
Fortran::common::LanguageFeature::BackslashEscapes),
|
||||||
nullptr /* action before each statement */,
|
nullptr /* action before each statement */,
|
||||||
driver.unparseTypedExprsToPGF90 ? &asFortran : nullptr);
|
driver.unparseTypedExprsToPGF90 ? &asFortran : nullptr);
|
||||||
Fortran::evaluate::formatForPGF90 = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ParentProcess()) {
|
if (ParentProcess()) {
|
||||||
|
|
Loading…
Reference in New Issue