[flang] Do not emit a prefix for a default-kind character constant in AsFortran
authorpeter klausler <pklausler@nvidia.com>
Tue, 17 Mar 2020 19:35:31 +0000 (12:35 -0700)
committerpeter klausler <pklausler@nvidia.com>
Tue, 17 Mar 2020 19:35:31 +0000 (12:35 -0700)
Original-commit: flang-compiler/f18@4a3db55727a93805d3f047713e5d253543ee51fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/1078

flang/include/flang/Evaluate/formatting.h
flang/lib/Evaluate/formatting.cpp
flang/test/Semantics/modfile16.f90
flang/test/Semantics/modfile20.f90
flang/test/Semantics/modfile21.f90
flang/test/Semantics/modfile22.f90
flang/test/Semantics/modfile28.f90
flang/test/Semantics/modfile30.f90
flang/tools/f18/f18.cpp

index 0a1f951..c2e5316 100644 (file)
@@ -26,8 +26,6 @@
 
 namespace Fortran::evaluate {
 
-extern bool formatForPGF90;
-
 template<typename A>
 auto operator<<(std::ostream &o, const A &x) -> decltype(x.AsFortran(o)) {
   return x.AsFortran(o);
index 560bfc5..4c28d66 100644 (file)
@@ -18,8 +18,6 @@
 
 namespace Fortran::evaluate {
 
-bool formatForPGF90{false};
-
 static void ShapeAsFortran(std::ostream &o, const ConstantSubscripts &shape) {
   if (GetRank(shape) > 1) {
     o << ",shape=";
@@ -87,7 +85,7 @@ std::ostream &Constant<Type<TypeCategory::Character, KIND>>::AsFortran(
     if (j > 0) {
       o << ',';
     }
-    if (Result::kind != 1 || !formatForPGF90) {
+    if (Result::kind != 1) {
       o << Result::kind << '_';
     }
     o << parser::QuoteCharacterLiteral(value);
index acc17d5..48a3027 100644 (file)
@@ -22,16 +22,16 @@ end
 
 !Expect: m.mod
 !module m
-!  character(2_4,1),parameter::prefix=1_"c_"
-!  integer(4),bind(c, name=1_"c_a")::a
-!  procedure(sub),bind(c, name=1_"c_b"),pointer::b
+!  character(2_4,1),parameter::prefix="c_"
+!  integer(4),bind(c, name="c_a")::a
+!  procedure(sub),bind(c, name="c_b"),pointer::b
 !  type,bind(c)::t
 !    real(4)::c
 !  end type
-!  procedure(real(4)),bind(c, name=1_"dd")::d
-!  procedure(real(4)),bind(c, name=1_"ee")::e
-!  procedure(real(4)),bind(c, name=1_"ff")::f
+!  procedure(real(4)),bind(c, name="dd")::d
+!  procedure(real(4)),bind(c, name="ee")::e
+!  procedure(real(4)),bind(c, name="ff")::f
 !contains
-!  subroutine sub() bind(c, name=1_"sub")
+!  subroutine sub() bind(c, name="sub")
 !  end
 !end
index 90188c1..a09c442 100644 (file)
@@ -26,7 +26,7 @@ end
 !  integer(8),parameter::i=2_8
 !  real(4)::r
 !  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::zn=(-1._8,2._8)
 !  type::t
index 03349a3..64dd95f 100644 (file)
@@ -30,6 +30,6 @@ end
 !  bind(c)::/cb2/
 !  common//t,w,u,v
 !  common/cb/x,y,z
-!  bind(c, name=1_"CB")::/cb/
+!  bind(c, name="CB")::/cb/
 !  common/b/cb
 !end
index 6279ad7..ea2637d 100644 (file)
@@ -18,6 +18,6 @@ end module m
 !character(1_4,int(k,kind=8))::a
 !character(3_4,int(k,kind=8))::b
 !end type
-!type(t(k=1_4)),parameter::p=t(k=1_4)(a=1_"x",b=1_"xx ")
-!character(2_4,1),parameter::c2(1_8:3_8)=[CHARACTER(KIND=1,LEN=2)::1_"x ",1_"xx",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)::"x ","xx","xx"]
 !end
index 18a349d..b06826c 100644 (file)
@@ -16,7 +16,7 @@ end module m
 !Expect: m.mod
 !module m
 !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"]
 !integer(4),parameter::lc4=7_4
 !intrinsic::len
index ef05b93..a3b4262 100644 (file)
@@ -75,7 +75,7 @@ end
 
 !Expect: m4a.mod
 !module m4a
-! character(1_4,1),parameter::a=1_"\001"
+! character(1_4,1),parameter::a="\001"
 ! intrinsic::achar
 !end
 
@@ -83,6 +83,6 @@ end
 !module m4b
 ! use m4a,only:a
 ! use m4a,only:achar
-! character(1_4,1),parameter::b=1_"\001"
+! character(1_4,1),parameter::b="\001"
 !end
 
index fe7bd8a..edcd0ef 100644 (file)
@@ -333,13 +333,11 @@ std::string CompileFortran(std::string path, Fortran::parser::Options options,
   {
     std::ofstream tmpSource;
     tmpSource.open(tmpSourcePath);
-    Fortran::evaluate::formatForPGF90 = true;
     Unparse(tmpSource, parseTree, driver.encoding, true /*capitalize*/,
         options.features.IsEnabled(
             Fortran::common::LanguageFeature::BackslashEscapes),
         nullptr /* action before each statement */,
         driver.unparseTypedExprsToPGF90 ? &asFortran : nullptr);
-    Fortran::evaluate::formatForPGF90 = false;
   }
 
   if (ParentProcess()) {