From e1ea983b0a447e141ed2260038142c1cae3a31ca Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Wed, 20 Mar 2019 13:52:33 -0700 Subject: [PATCH] [flang] Dump function return attributes Also, change SubprogramDetails::result_ from `std::optional` to `Symbol *`. We don't need two levels of optional-ness. Original-commit: flang-compiler/f18@db3b874946dc9b139009d7e10832edb2a076a7bc Reviewed-on: https://github.com/flang-compiler/f18/pull/368 Tree-same-pre-rewrite: false --- flang/lib/semantics/symbol.cc | 5 ++++- flang/lib/semantics/symbol.h | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flang/lib/semantics/symbol.cc b/flang/lib/semantics/symbol.cc index 34189b2..eb748cf 100644 --- a/flang/lib/semantics/symbol.cc +++ b/flang/lib/semantics/symbol.cc @@ -56,7 +56,10 @@ std::ostream &operator<<(std::ostream &os, const SubprogramDetails &x) { os << " bindName:" << x.bindName_; } if (x.result_) { - os << " result:" << x.result_.value()->name(); + os << " result:" << x.result_->name(); + if (!x.result_->attrs().empty()) { + os << ", " << x.result_->attrs(); + } } if (x.dummyArgs_.empty()) { char sep{'('}; diff --git a/flang/lib/semantics/symbol.h b/flang/lib/semantics/symbol.h index 5abc104..1356605 100644 --- a/flang/lib/semantics/symbol.h +++ b/flang/lib/semantics/symbol.h @@ -60,17 +60,17 @@ public: SubprogramDetails(const SubprogramDetails &that) : dummyArgs_{that.dummyArgs_}, result_{that.result_} {} - bool isFunction() const { return result_.has_value(); } + bool isFunction() const { return result_ != nullptr; } bool isInterface() const { return isInterface_; } void set_isInterface(bool value = true) { isInterface_ = value; } MaybeExpr bindName() const { return bindName_; } void set_bindName(MaybeExpr &&expr) { bindName_ = std::move(expr); } const Symbol &result() const { CHECK(isFunction()); - return **result_; + return *result_; } void set_result(Symbol &result) { - CHECK(!result_.has_value()); + CHECK(result_ == nullptr); result_ = &result; } const std::list &dummyArgs() const { return dummyArgs_; } @@ -80,7 +80,7 @@ private: bool isInterface_{false}; // true if this represents an interface-body MaybeExpr bindName_; std::list dummyArgs_; - std::optional result_; + Symbol *result_{nullptr}; friend std::ostream &operator<<(std::ostream &, const SubprogramDetails &); }; -- 2.7.4