From: peter klausler Date: Tue, 18 Sep 2018 18:59:25 +0000 (-0700) Subject: [flang] check C1002 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0787d7f2df897e84947809cc3d7d1c81b403ec1a;p=platform%2Fupstream%2Fllvm.git [flang] check C1002 Original-commit: flang-compiler/f18@6a2fd760b4e38fe126b70a84e2b2e7dde62708be Reviewed-on: https://github.com/flang-compiler/f18/pull/195 Tree-same-pre-rewrite: false --- diff --git a/flang/lib/semantics/expression.cc b/flang/lib/semantics/expression.cc index accc561..752c980 100644 --- a/flang/lib/semantics/expression.cc +++ b/flang/lib/semantics/expression.cc @@ -245,10 +245,23 @@ MaybeExpr AnalyzeHelper(ExprAnalyzer &ea, const parser::Designator &d) { if (std::optional dataRef{ExtractDataRef(std::move(result))}) { if (Component * component{std::get_if(&dataRef->u)}) { ea.ComponentRankCheck(*component); - } else if (const Symbol **symbol{ + } else if (const Symbol **symbolPointer{ std::get_if(&dataRef->u)}) { - // TODO: Whole array reference: append : subscripts, enforce C1002 - // Possibly use EA::Subscripts() below. + const Symbol &symbol{**symbolPointer}; + if (const auto *details{ + symbol.detailsIf()}) { + if (details->isArray()) { + if (details->isAssumedSize()) { // C1002 + // TODO: it's okay to forward an assumed-size array as an argument + // to many functions and all subroutines, though + ea.context.messages.Say( + "assumed-size array '%s' must have subscripts in expression"_err_en_US, + symbol.name().ToString().data()); + } + // TODO: Whole array reference: append : subscripts, enforce C1002 + // Possibly use EA::Subscripts() below. + } + } } } return result; @@ -642,7 +655,6 @@ MaybeExpr ExprAnalyzer::Subscripts(const Symbol &symbol, ArrayRef &&ref) { symbolRank, symbol.name().ToString().data(), subscripts); } // TODO: fill in bounds of triplets? - // TODO: subtract lowers bounds? // TODO: enforce constraints, like lack of uppermost bound on assumed-size if (Component * component{std::get_if(&ref.u)}) { int baseRank{component->Rank()}; diff --git a/flang/lib/semantics/symbol.h b/flang/lib/semantics/symbol.h index d27daf0..8ae7f24 100644 --- a/flang/lib/semantics/symbol.h +++ b/flang/lib/semantics/symbol.h @@ -120,6 +120,10 @@ public: void set_shape(const ArraySpec &shape); bool isDummy() const { return isDummy_; } bool isArray() const { return !shape_.empty(); } + bool isAssumedSize() const { + return isDummy() && isArray() && shape_.back().ubound().isAssumed() && + !shape_.back().lbound().isAssumed(); + } private: bool isDummy_;