[flang] Address review comments
authorTim Keith <tkeith@nvidia.com>
Wed, 5 Sep 2018 23:02:41 +0000 (16:02 -0700)
committerTim Keith <tkeith@nvidia.com>
Wed, 5 Sep 2018 23:02:41 +0000 (16:02 -0700)
Original-commit: flang-compiler/f18@2ca329b85a3e6113f417dff25ba39898bd8869e8
Reviewed-on: https://github.com/flang-compiler/f18/pull/173

flang/lib/common/fortran.h
flang/lib/parser/grammar.h
flang/lib/parser/parse-tree.h
flang/lib/parser/unparse.cc
flang/lib/semantics/dump-parse-tree.h
flang/lib/semantics/mod-file.cc
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h

index 443732edd1e939eff45cfddc3e315796831fff19..39ef486587f8abe36270adadcb6df3127f471dee 100644 (file)
@@ -28,8 +28,8 @@ ENUM_CLASS(TypeCategory, Integer, Real, Complex, Character, Logical, Derived)
 // Kinds of IMPORT statements. Default means IMPORT or IMPORT :: names.
 ENUM_CLASS(ImportKind, Default, Only, None, All)
 
-// Type parameters can be kind or len.
-ENUM_CLASS(TypeParamKindOrLen, Kind, Len)
+// The attribute on a type parameter can be KIND or LEN.
+ENUM_CLASS(TypeParamAttr, Kind, Len)
 
 }  // namespace Fortran::common
 #endif  // FORTRAN_COMMON_FORTRAN_H_
index 359c4b91f667c6d4afe74d690fc0f0075adcbb04..29c5b889f3f5e539f2f59ef30c37b4f650793418 100644 (file)
@@ -740,8 +740,8 @@ TYPE_PARSER(construct<SequenceStmt>("SEQUENCE"_tok))
 //        integer-type-spec , type-param-attr-spec :: type-param-decl-list
 // R734 type-param-attr-spec -> KIND | LEN
 TYPE_PARSER(construct<TypeParamDefStmt>(integerTypeSpec / ",",
-    "KIND" >> pure(common::TypeParamKindOrLen::Kind) ||
-        "LEN" >> pure(common::TypeParamKindOrLen::Len),
+    "KIND" >> pure(common::TypeParamAttr::Kind) ||
+        "LEN" >> pure(common::TypeParamAttr::Len),
     "::" >> nonemptyList(Parser<TypeParamDecl>{})))
 
 // R733 type-param-decl -> type-param-name [= scalar-int-constant-expr]
index 0604d0d4b2a0db717b0e611835df37acc75b42ab..34aa5bea45119d0dfb13409af94209157f4af70a 100644 (file)
@@ -890,8 +890,7 @@ struct TypeParamDecl {
 // R734 type-param-attr-spec -> KIND | LEN
 struct TypeParamDefStmt {
   TUPLE_CLASS_BOILERPLATE(TypeParamDefStmt);
-  std::tuple<IntegerTypeSpec, common::TypeParamKindOrLen,
-      std::list<TypeParamDecl>>
+  std::tuple<IntegerTypeSpec, common::TypeParamAttr, std::list<TypeParamDecl>>
       t;
 };
 
index ce3e938cfe281dc9ca87ac7f136c2d3b89a5f4ed..11bdef4c9c3dbb1de8e5c81a0fc7f6ebe1219839 100644 (file)
@@ -222,7 +222,7 @@ public:
   }
   void Unparse(const TypeParamDefStmt &x) {  // R732
     Walk(std::get<IntegerTypeSpec>(x.t));
-    Put(", "), Walk(std::get<common::TypeParamKindOrLen>(x.t));
+    Put(", "), Walk(std::get<common::TypeParamAttr>(x.t));
     Put(" :: "), Walk(std::get<std::list<TypeParamDecl>>(x.t), ", ");
   }
   void Unparse(const TypeParamDecl &x) {  // R733
@@ -2333,7 +2333,7 @@ public:
 #define WALK_NESTED_ENUM(CLASS, ENUM) \
   void Unparse(const CLASS::ENUM &x) { Word(CLASS::EnumToString(x)); }
   WALK_NESTED_ENUM(AccessSpec, Kind)  // R807
-  WALK_NESTED_ENUM(common, TypeParamKindOrLen)  // R734
+  WALK_NESTED_ENUM(common, TypeParamAttr)  // R734
   WALK_NESTED_ENUM(IntentSpec, Intent)  // R826
   WALK_NESTED_ENUM(ImplicitStmt, ImplicitNoneNameSpec)  // R866
   WALK_NESTED_ENUM(ConnectSpec::CharExpr, Kind)  // R1205
index 97b592f1432708541004ec7c0b3c85d40cc5b8c8..9fe2d43ee122e55b31b9af58c4cde03d4614ac8d 100644 (file)
@@ -680,7 +680,7 @@ public:
   NODE(parser::TypeGuardStmt, Guard)
   NODE(parser, TypeParamDecl)
   NODE(parser, TypeParamDefStmt)
-  NODE(common, TypeParamKindOrLen)
+  NODE(common, TypeParamAttr)
   NODE(parser, TypeParamInquiry)
   NODE(parser, TypeParamSpec)
   NODE(parser, TypeParamValue)
index ba7e206fb17dd1c1250978653b23941798464591..b53b393dd02e02005c2b366b0f2f8d835e12d8e2 100644 (file)
@@ -345,8 +345,8 @@ void PutTypeParam(std::ostream &os, const Symbol &symbol) {
     auto *type{symbol.GetType()};
     CHECK(type);
     PutLower(os, *type);
-    PutLower(os << ',',
-        common::EnumToString(symbol.get<TypeParamDetails>().kindOrLen()));
+    PutLower(
+        os << ',', common::EnumToString(symbol.get<TypeParamDetails>().attr()));
   });
 }
 
index e7dac7b30ac47ec576fcd15f1f3742f2fbde6ee5..69de03856319935950db33bad112d8c4234b2f7a 100644 (file)
@@ -79,7 +79,7 @@ private:
 // Provide Post methods to collect attributes into a member variable.
 class AttrsVisitor {
 public:
-  bool BeginAttrs();
+  bool BeginAttrs();  // always returns true
   Attrs GetAttrs();
   Attrs EndAttrs();
   void Post(const parser::LanguageBindingSpec &);
@@ -2088,13 +2088,13 @@ void DeclarationVisitor::Post(const parser::DerivedTypeStmt &x) {
 }
 void DeclarationVisitor::Post(const parser::TypeParamDefStmt &x) {
   auto &type{GetDeclTypeSpec()};
-  auto kindOrLen{std::get<common::TypeParamKindOrLen>(x.t)};
+  auto attr{std::get<common::TypeParamAttr>(x.t)};
   for (auto &decl : std::get<std::list<parser::TypeParamDecl>>(x.t)) {
     auto &name{std::get<parser::Name>(decl.t).source};
     // TODO: initialization
     // auto &init{
     //    std::get<std::optional<parser::ScalarIntConstantExpr>>(decl.t)};
-    auto &symbol{MakeTypeSymbol(name, TypeParamDetails{kindOrLen})};
+    auto &symbol{MakeTypeSymbol(name, TypeParamDetails{attr})};
     SetType(name, symbol, *type);
   }
   EndDecl();
index 51ec0d6396c31e81787982b4e1b45892a552ef01..42d51d42bbcb9685d0f96829cefd140896b26e09 100644 (file)
@@ -359,7 +359,7 @@ std::ostream &operator<<(std::ostream &os, const Details &details) {
             if (x.type()) {
               os << ' ' << *x.type();
             }
-            os << ' ' << common::EnumToString(x.kindOrLen());
+            os << ' ' << common::EnumToString(x.attr());
           },
       },
       details);
index d59d839e8c900822f5da285253244c37dc70ace7..4848e8bcda5f3a1da3128497f2b429f9e4b32ee7 100644 (file)
@@ -168,9 +168,8 @@ class FinalProcDetails {};
 
 class TypeParamDetails {
 public:
-  TypeParamDetails(common::TypeParamKindOrLen kindOrLen)
-    : kindOrLen_{kindOrLen} {}
-  common::TypeParamKindOrLen kindOrLen() const { return kindOrLen_; }
+  TypeParamDetails(common::TypeParamAttr attr) : attr_{attr} {}
+  common::TypeParamAttr attr() const { return attr_; }
   const std::optional<DeclTypeSpec> &type() const { return type_; }
   void set_type(const DeclTypeSpec &type) {
     CHECK(!type_);
@@ -178,7 +177,7 @@ public:
   }
 
 private:
-  common::TypeParamKindOrLen kindOrLen_;
+  common::TypeParamAttr attr_;
   std::optional<DeclTypeSpec> type_;
 };