[flang-commits] [flang] d134442 - [flang][nfc] Use a message class for "not yet implemented" messages
Peter Steinfeld via flang-commits
flang-commits at lists.llvm.org
Thu May 5 07:12:42 PDT 2022
Author: Peter Steinfeld
Date: 2022-05-05T07:12:22-07:00
New Revision: d1344422009732991767bdcaf57dbedd946c7761
URL: https://github.com/llvm/llvm-project/commit/d1344422009732991767bdcaf57dbedd946c7761
DIFF: https://github.com/llvm/llvm-project/commit/d1344422009732991767bdcaf57dbedd946c7761.diff
LOG: [flang][nfc] Use a message class for "not yet implemented" messages
Following a previous suggestion from Peter Klausler.
Differential Revision: https://reviews.llvm.org/D124972
Added:
Modified:
flang/include/flang/Parser/message.h
flang/lib/Parser/message.cpp
flang/lib/Semantics/expression.cpp
flang/lib/Semantics/resolve-names.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Parser/message.h b/flang/include/flang/Parser/message.h
index 80a03401feea5..017d141a41ba5 100644
--- a/flang/include/flang/Parser/message.h
+++ b/flang/include/flang/Parser/message.h
@@ -32,13 +32,15 @@ namespace Fortran::parser {
// Use "..."_err_en_US, "..."_warn_en_US, "..."_port_en_US, and "..."_en_US
// string literals to define the static text and fatality of a message.
//
-// Error: fatal error that prevents code and module file generation
-// Warning: likely problem,
-// Portability: nonstandard or obsolete features
-// Because: for AttachTo(), explanatory attachment in support of another message
-// Context (internal): attachment from SetContext()
-// None: everything else, common for attachments with source locations
-enum class Severity { Error, Warning, Portability, Because, Context, None };
+enum class Severity {
+ Error, // fatal error that prevents code and module file generation
+ Warning, // likely problem
+ Portability, // nonstandard or obsolete features
+ Because, // for AttachTo(), explanatory attachment to support another message
+ Context, // (internal): attachment from SetContext()
+ Todo, // a feature that's not yet implemented, a fatal error
+ None // everything else, common for attachments with source locations
+};
class MessageFixedText {
public:
@@ -57,7 +59,9 @@ class MessageFixedText {
severity_ = severity;
return *this;
}
- bool isFatal() const { return severity_ == Severity::Error; }
+ bool isFatal() const {
+ return severity_ == Severity::Error || severity_ == Severity::Todo;
+ }
private:
CharBlock text_;
@@ -77,6 +81,10 @@ constexpr MessageFixedText operator""_port_en_US(
const char str[], std::size_t n) {
return MessageFixedText{str, n, Severity::Portability};
}
+constexpr MessageFixedText operator""_todo_en_US(
+ const char str[], std::size_t n) {
+ return MessageFixedText{str, n, Severity::Todo};
+}
constexpr MessageFixedText operator""_en_US(const char str[], std::size_t n) {
return MessageFixedText{str, n, Severity::None};
}
@@ -99,7 +107,9 @@ class MessageFormattedText {
MessageFormattedText &operator=(const MessageFormattedText &) = default;
MessageFormattedText &operator=(MessageFormattedText &&) = default;
const std::string &string() const { return string_; }
- bool isFatal() const { return severity_ == Severity::Error; }
+ bool isFatal() const {
+ return severity_ == Severity::Error || severity_ == Severity::Todo;
+ }
Severity severity() const { return severity_; }
MessageFormattedText &set_severity(Severity severity) {
severity_ = severity;
diff --git a/flang/lib/Parser/message.cpp b/flang/lib/Parser/message.cpp
index 18e6b3784be3e..081dd5c78e61a 100644
--- a/flang/lib/Parser/message.cpp
+++ b/flang/lib/Parser/message.cpp
@@ -155,7 +155,9 @@ bool Message::SortBefore(const Message &that) const {
location_, that.location_);
}
-bool Message::IsFatal() const { return severity() == Severity::Error; }
+bool Message::IsFatal() const {
+ return severity() == Severity::Error || severity() == Severity::Todo;
+}
Severity Message::severity() const {
return common::visit(
@@ -224,6 +226,8 @@ static std::string Prefix(Severity severity) {
return "because: ";
case Severity::Context:
return "in the context: ";
+ case Severity::Todo:
+ return "error: not yet implemented: ";
case Severity::None:
break;
}
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 146e4d1249f94..7b3e37f358d15 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -3227,12 +3227,10 @@ void ArgumentAnalyzer::Analyze(
actual = ActualArgument(label.v);
},
[&](const parser::ActualArg::PercentRef &) {
- context_.Say(
- "not yet implemented: %REF() intrinsic for arguments"_err_en_US);
+ context_.Say("%REF() intrinsic for arguments"_todo_en_US);
},
[&](const parser::ActualArg::PercentVal &) {
- context_.Say(
- "not yet implemetned: %VAL() intrinsic for arguments"_err_en_US);
+ context_.Say("%VAL() intrinsic for arguments"_todo_en_US);
},
},
std::get<parser::ActualArg>(arg.t).u);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 60820040dbe1a..cc02cccdfb1ad 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -774,9 +774,7 @@ class InterfaceVisitor : public virtual ScopeHandler {
bool isAbstract() const;
protected:
- Symbol &GetGenericSymbol() {
- return DEREF(genericInfo_.top().symbol);
- }
+ Symbol &GetGenericSymbol() { return DEREF(genericInfo_.top().symbol); }
// Add to generic the symbol for the subprogram with the same name
void CheckGenericProcedures(Symbol &);
@@ -4895,7 +4893,7 @@ bool DeclarationVisitor::Pre(const parser::StructureDef &def) {
}
bool DeclarationVisitor::Pre(const parser::Union::UnionStmt &) {
- Say("not yet implemented: support for UNION"_err_en_US); // TODO
+ Say("support for UNION"_todo_en_US); // TODO
return true;
}
More information about the flang-commits
mailing list