forked from OSchip/llvm-project
[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
This commit is contained in:
parent
17d27d926b
commit
d134442200
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -774,9 +774,7 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue