From c7eb38530cabc5fdb44ee32560f38592cb9e7a78 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Fri, 22 Jun 2018 14:08:04 -0700 Subject: [PATCH] [flang] Fix problems in PR 109 when compiling with clang. This gets the code base back to compiling cleanly with clang after pull request 109. There were two overloadings of `Post(const parser::DeclarationTypeSpec::Type &)`. The one in DeclarationVisitor needed to call the one in DeclTypeSpecVisitor. This was fixed by introducing a new function, SetDerivedDeclTypeSpec, to do the equivalent thing. Original-commit: flang-compiler/f18@81e447bf4ec076f8fa823c0c61c9dd72e1f62fe4 Reviewed-on: https://github.com/flang-compiler/f18/pull/110 --- flang/lib/semantics/resolve-names.cc | 17 ++++++++++------- flang/lib/semantics/symbol.h | 2 +- flang/lib/semantics/type.h | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc index daf99a6..afa43bd 100644 --- a/flang/lib/semantics/resolve-names.cc +++ b/flang/lib/semantics/resolve-names.cc @@ -131,7 +131,6 @@ public: bool Pre(const parser::IntrinsicTypeSpec::DoublePrecision &); bool Pre(const parser::DeclarationTypeSpec::ClassStar &); bool Pre(const parser::DeclarationTypeSpec::TypeStar &); - void Post(const parser::DeclarationTypeSpec::Type &); void Post(const parser::DeclarationTypeSpec::Class &); bool Pre(const parser::DeclarationTypeSpec::Record &); void Post(const parser::TypeParamSpec &); @@ -147,6 +146,7 @@ protected: void BeginDeclTypeSpec(); void EndDeclTypeSpec(); void BeginDerivedTypeSpec(DerivedTypeSpec &); + void SetDerivedDeclTypeSpec(DeclTypeSpec::Category); private: bool expectDeclTypeSpec_{false}; // should only see decl-type-spec when true @@ -803,11 +803,8 @@ bool DeclTypeSpecVisitor::Pre(const parser::TypeParamValue &x) { return false; } -void DeclTypeSpecVisitor::Post(const parser::DeclarationTypeSpec::Type &) { - SetDeclTypeSpec(DeclTypeSpec{DeclTypeSpec::TypeDerived, *derivedTypeSpec_}); -} void DeclTypeSpecVisitor::Post(const parser::DeclarationTypeSpec::Class &) { - SetDeclTypeSpec(DeclTypeSpec{DeclTypeSpec::ClassDerived, *derivedTypeSpec_}); + SetDerivedDeclTypeSpec(DeclTypeSpec::ClassDerived); } bool DeclTypeSpecVisitor::Pre(const parser::DeclarationTypeSpec::Record &x) { // TODO @@ -862,6 +859,13 @@ void DeclTypeSpecVisitor::MakeIntrinsic( const IntrinsicTypeSpec &intrinsicTypeSpec) { SetDeclTypeSpec(DeclTypeSpec{intrinsicTypeSpec}); } + +// Set declTypeSpec_ based on derivedTypeSpec_ +void DeclTypeSpecVisitor::SetDerivedDeclTypeSpec( + DeclTypeSpec::Category category) { + SetDeclTypeSpec(DeclTypeSpec{category, *derivedTypeSpec_}); +} + void DeclTypeSpecVisitor::BeginDerivedTypeSpec( DerivedTypeSpec &derivedTypeSpec) { CHECK(!derivedTypeSpec_); @@ -1845,7 +1849,7 @@ void DeclarationVisitor::DeclareObjectEntity( } void DeclarationVisitor::Post(const parser::DeclarationTypeSpec::Type &x) { - DeclTypeSpecVisitor::Post(x); + SetDerivedDeclTypeSpec(DeclTypeSpec::TypeDerived); DerivedTypeSpec &type{GetDeclTypeSpec()->derivedTypeSpec()}; if (const auto *symbol = ResolveDerivedType(type.name())) { if (!symbol->has()) { @@ -1897,7 +1901,6 @@ bool DeclarationVisitor::Pre(const parser::SequenceStmt &x) { } void DeclarationVisitor::Post(const parser::ComponentDecl &x) { const auto &name = std::get(x.t); - Attrs attrs{attrs_ ? *attrs_ : Attrs{}}; DeclareObjectEntity(name, GetAttrs()); ClearArraySpec(); } diff --git a/flang/lib/semantics/symbol.h b/flang/lib/semantics/symbol.h index 7f8c53c..798e129 100644 --- a/flang/lib/semantics/symbol.h +++ b/flang/lib/semantics/symbol.h @@ -295,7 +295,7 @@ private: const std::string GetDetailsName() const; friend std::ostream &operator<<(std::ostream &, const Symbol &); template friend class Symbols; - template friend class std::array; + template friend struct std::array; }; std::ostream &operator<<(std::ostream &, Symbol::Flag); diff --git a/flang/lib/semantics/type.h b/flang/lib/semantics/type.h index 29b754c..a28ab67 100644 --- a/flang/lib/semantics/type.h +++ b/flang/lib/semantics/type.h @@ -566,6 +566,7 @@ public: std::ostream &Output(std::ostream &o) const override { return o << *this; } explicit DerivedTypeSpec(const SourceName &name) : name_{&name} {} DerivedTypeSpec() = delete; + virtual ~DerivedTypeSpec() {} const SourceName &name() const { return *name_; } const Scope *scope() const { return scope_; } void set_scope(const Scope &); -- 2.7.4