forked from OSchip/llvm-project
[flang] Add contextualizing interfaces to ExpressionAnalyzer and ContextualMessages
Original-commit: flang-compiler/f18@30a004d7b1 Reviewed-on: https://github.com/flang-compiler/f18/pull/790
This commit is contained in:
parent
f39e704606
commit
b5eec67fc4
|
@ -285,6 +285,7 @@ public:
|
|||
|
||||
CharBlock at() const { return at_; }
|
||||
Messages *messages() const { return messages_; }
|
||||
bool empty() const { return !messages_ || messages_->empty(); }
|
||||
|
||||
// Set CharBlock for messages; restore when the returned value is deleted
|
||||
common::Restorer<CharBlock> SetLocation(CharBlock at) {
|
||||
|
@ -294,6 +295,12 @@ public:
|
|||
return common::ScopedSet(at_, std::move(at));
|
||||
}
|
||||
|
||||
// Diverts messages to another buffer; restored when the returned
|
||||
// value is deleted.
|
||||
common::Restorer<Messages *> SetMessages(Messages &buffer) {
|
||||
return common::ScopedSet(messages_, &buffer);
|
||||
}
|
||||
|
||||
template<typename... A> Message *Say(CharBlock at, A &&... args) {
|
||||
if (messages_ != nullptr) {
|
||||
return &messages_->Say(at, std::forward<A>(args)...);
|
||||
|
|
|
@ -885,7 +885,7 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::StructureComponent &sc) {
|
|||
"a designator"_err_en_US);
|
||||
}
|
||||
} else if (dtSpec == nullptr || dtSpec->scope() == nullptr) {
|
||||
CHECK(context_.AnyFatalError());
|
||||
CHECK(context_.AnyFatalError() || !foldingContext_.messages().empty());
|
||||
return std::nullopt;
|
||||
} else if (std::optional<DataRef> dataRef{
|
||||
ExtractDataRef(std::move(*dtExpr))}) {
|
||||
|
@ -1534,7 +1534,7 @@ auto ExpressionAnalyzer::AnalyzeProcedureComponentRef(
|
|||
}
|
||||
}
|
||||
}
|
||||
CHECK(context_.messages().AnyFatalError());
|
||||
CHECK(!GetContextualMessages().empty());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,16 +121,16 @@ public:
|
|||
using MaybeExpr = std::optional<Expr<SomeType>>;
|
||||
|
||||
explicit ExpressionAnalyzer(semantics::SemanticsContext &sc) : context_{sc} {}
|
||||
ExpressionAnalyzer(semantics::SemanticsContext &sc, FoldingContext &fc)
|
||||
: context_{sc}, foldingContext_{fc} {}
|
||||
ExpressionAnalyzer(ExpressionAnalyzer &) = default;
|
||||
|
||||
semantics::SemanticsContext &context() const { return context_; }
|
||||
|
||||
FoldingContext &GetFoldingContext() const {
|
||||
return context_.foldingContext();
|
||||
}
|
||||
FoldingContext &GetFoldingContext() const { return foldingContext_; }
|
||||
|
||||
parser::ContextualMessages &GetContextualMessages() {
|
||||
return GetFoldingContext().messages();
|
||||
return foldingContext_.messages();
|
||||
}
|
||||
|
||||
template<typename... A> parser::Message *Say(A &&... args) {
|
||||
|
@ -341,6 +341,7 @@ private:
|
|||
MaybeExpr MakeFunctionRef(parser::CharBlock intrinsic, ActualArguments &&);
|
||||
|
||||
semantics::SemanticsContext &context_;
|
||||
FoldingContext &foldingContext_{context_.foldingContext()};
|
||||
std::map<parser::CharBlock, int> acImpliedDos_; // values are INTEGER kinds
|
||||
bool fatalErrors_{false};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue