[flang-commits] [flang] 008e697 - [flang] Fix regressions found in testing
peter klausler via flang-commits
flang-commits at lists.llvm.org
Thu Apr 9 08:15:31 PDT 2020
Author: peter klausler
Date: 2019-07-08T16:02:50-07:00
New Revision: 008e697192b18752ff5e7e7c51725da86d54763d
URL: https://github.com/llvm/llvm-project/commit/008e697192b18752ff5e7e7c51725da86d54763d
DIFF: https://github.com/llvm/llvm-project/commit/008e697192b18752ff5e7e7c51725da86d54763d.diff
LOG: [flang] Fix regressions found in testing
Original-commit: flang-compiler/f18 at ea09b191dfbcb00097a44df3aae3bdbd5f6e8392
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
Added:
Modified:
flang/lib/evaluate/variable.cc
flang/lib/semantics/resolve-names.cc
Removed:
################################################################################
diff --git a/flang/lib/evaluate/variable.cc b/flang/lib/evaluate/variable.cc
index 8e187b461cc4..029c8b133dd8 100644
--- a/flang/lib/evaluate/variable.cc
+++ b/flang/lib/evaluate/variable.cc
@@ -185,6 +185,9 @@ std::optional<Expr<SomeCharacter>> Substring::Fold(FoldingContext &context) {
}
if (!upper_.has_value()) {
upper_ = upper();
+ if (!upper_.has_value()) {
+ return std::nullopt;
+ }
}
upper_.value() = evaluate::Fold(context, std::move(upper_.value().value()));
if (std::optional<ConstantSubscript> ubi{ToInt64(upper_.value().value())}) {
diff --git a/flang/lib/semantics/resolve-names.cc b/flang/lib/semantics/resolve-names.cc
index 6310bbd30fad..6313e7469d3d 100644
--- a/flang/lib/semantics/resolve-names.cc
+++ b/flang/lib/semantics/resolve-names.cc
@@ -776,7 +776,8 @@ class DeclarationVisitor : public ArraySpecVisitor,
private:
// The attribute corresponding to the statement containing an ObjectDecl
std::optional<Attr> objectDeclAttr_;
- // Info about current character type while walking DeclTypeSpec
+ // Info about current character type while walking DeclTypeSpec.
+ // Also captures any "*length" specifier on an individual declaration.
struct {
std::optional<ParamValue> length;
std::optional<KindExpr> kind;
@@ -2731,6 +2732,7 @@ Symbol &DeclarationVisitor::DeclareUnknownEntity(
if (auto *type{GetDeclTypeSpec()}) {
SetType(name, *type);
}
+ charInfo_.length.reset();
SetBindNameOn(symbol);
if (symbol.attrs().test(Attr::EXTERNAL)) {
ConvertToProcEntity(symbol);
@@ -2786,6 +2788,7 @@ Symbol &DeclarationVisitor::DeclareObjectEntity(
}
SetBindNameOn(symbol);
}
+ charInfo_.length.reset();
return symbol;
}
@@ -3820,6 +3823,9 @@ Symbol *DeclarationVisitor::DeclareStatementEntity(const parser::Name &name,
declTypeSpec = ProcessTypeSpec(*type);
}
if (declTypeSpec != nullptr) {
+ // Subtlety: Don't let a "*length" specifier (if any is pending) affect the
+ // declaration of this implied DO loop control variable.
+ auto save{common::ScopedSet(charInfo_.length, std::optional<ParamValue>{})};
SetType(name, *declTypeSpec);
} else {
ApplyImplicitRules(symbol);
More information about the flang-commits
mailing list