forked from OSchip/llvm-project
[flang] Merge with recent changes
Original-commit: flang-compiler/f18@56a72cbbd6 Reviewed-on: https://github.com/flang-compiler/f18/pull/444 Tree-same-pre-rewrite: false
This commit is contained in:
parent
ec6cf76536
commit
f704d38129
|
@ -64,6 +64,11 @@ const char *MessageFormattedText::Convert(const std::string &s) {
|
||||||
return conversions_.front().c_str();
|
return conversions_.front().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *MessageFormattedText::Convert(std::string &s) {
|
||||||
|
conversions_.emplace_front(s);
|
||||||
|
return conversions_.front().c_str();
|
||||||
|
}
|
||||||
|
|
||||||
const char *MessageFormattedText::Convert(std::string &&s) {
|
const char *MessageFormattedText::Convert(std::string &&s) {
|
||||||
conversions_.emplace_front(std::move(s));
|
conversions_.emplace_front(std::move(s));
|
||||||
return conversions_.front().c_str();
|
return conversions_.front().c_str();
|
||||||
|
@ -73,6 +78,10 @@ const char *MessageFormattedText::Convert(const CharBlock &x) {
|
||||||
return Convert(x.ToString());
|
return Convert(x.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *MessageFormattedText::Convert(CharBlock &x) {
|
||||||
|
return Convert(x.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
const char *MessageFormattedText::Convert(CharBlock &&x) {
|
const char *MessageFormattedText::Convert(CharBlock &&x) {
|
||||||
return Convert(x.ToString());
|
return Convert(x.ToString());
|
||||||
}
|
}
|
||||||
|
@ -81,6 +90,8 @@ const char *MessageFormattedText::Convert(const Name &n) {
|
||||||
return Convert(n.source);
|
return Convert(n.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *MessageFormattedText::Convert(Name &n) { return Convert(n.source); }
|
||||||
|
|
||||||
const char *MessageFormattedText::Convert(Name &&n) {
|
const char *MessageFormattedText::Convert(Name &&n) {
|
||||||
return Convert(n.source);
|
return Convert(n.source);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,15 +90,18 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Format(const MessageFixedText *text, ...);
|
void Format(const MessageFixedText *text, ...);
|
||||||
template<typename A> A Convert(const A &x) { return x; }
|
template<typename A> A Convert(A &x) { return x; }
|
||||||
template<typename A> common::IfNoLvalue<A, A> Convert(A &&x) {
|
template<typename A> common::IfNoLvalue<A, A> Convert(A &&x) {
|
||||||
return std::move(x);
|
return std::move(x);
|
||||||
}
|
}
|
||||||
const char *Convert(const std::string &);
|
const char *Convert(const std::string &);
|
||||||
|
const char *Convert(std::string &);
|
||||||
const char *Convert(std::string &&);
|
const char *Convert(std::string &&);
|
||||||
const char *Convert(const CharBlock &);
|
const char *Convert(const CharBlock &);
|
||||||
|
const char *Convert(CharBlock &);
|
||||||
const char *Convert(CharBlock &&);
|
const char *Convert(CharBlock &&);
|
||||||
const char *Convert(const Name &);
|
const char *Convert(const Name &);
|
||||||
|
const char *Convert(Name &);
|
||||||
const char *Convert(Name &&);
|
const char *Convert(Name &&);
|
||||||
|
|
||||||
bool isFatal_{false};
|
bool isFatal_{false};
|
||||||
|
|
|
@ -1056,9 +1056,8 @@ void ImplicitRules::SetType(const DeclTypeSpec &type, parser::Location lo,
|
||||||
for (char ch = *lo; ch; ch = ImplicitRules::Incr(ch)) {
|
for (char ch = *lo; ch; ch = ImplicitRules::Incr(ch)) {
|
||||||
auto res{map_.emplace(ch, &type)};
|
auto res{map_.emplace(ch, &type)};
|
||||||
if (!res.second && !isDefault) {
|
if (!res.second && !isDefault) {
|
||||||
context_.Say(lo,
|
context_.Say(parser::CharBlock{lo},
|
||||||
"More than one implicit type specified for '%s'"_err_en_US,
|
"More than one implicit type specified for '%c'"_err_en_US, ch);
|
||||||
std::string(1, ch).c_str());
|
|
||||||
}
|
}
|
||||||
if (ch == *hi) {
|
if (ch == *hi) {
|
||||||
break;
|
break;
|
||||||
|
@ -1289,12 +1288,11 @@ Message &MessageHandler::Say(const SourceName &name, MessageFixedText &&msg) {
|
||||||
}
|
}
|
||||||
Message &MessageHandler::Say(const SourceName &location, MessageFixedText &&msg,
|
Message &MessageHandler::Say(const SourceName &location, MessageFixedText &&msg,
|
||||||
const SourceName &arg1) {
|
const SourceName &arg1) {
|
||||||
return context_->Say(location, std::move(msg), arg1.ToString().c_str());
|
return context_->Say(location, std::move(msg), arg1);
|
||||||
}
|
}
|
||||||
Message &MessageHandler::Say(const SourceName &location, MessageFixedText &&msg,
|
Message &MessageHandler::Say(const SourceName &location, MessageFixedText &&msg,
|
||||||
const SourceName &arg1, const SourceName &arg2) {
|
const SourceName &arg1, const SourceName &arg2) {
|
||||||
return context_->Say(location, std::move(msg), arg1.ToString().c_str(),
|
return context_->Say(location, std::move(msg), arg1, arg2);
|
||||||
arg2.ToString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImplicitRulesVisitor implementation
|
// ImplicitRulesVisitor implementation
|
||||||
|
@ -1469,11 +1467,9 @@ void ScopeHandler::SayAlreadyDeclared(const SourceName &name, Symbol &prev) {
|
||||||
if (const auto *details{prev.detailsIf<UseDetails>()}) {
|
if (const auto *details{prev.detailsIf<UseDetails>()}) {
|
||||||
msg.Attach(details->location(),
|
msg.Attach(details->location(),
|
||||||
"It is use-associated with '%s' in module '%s'"_err_en_US,
|
"It is use-associated with '%s' in module '%s'"_err_en_US,
|
||||||
details->symbol().name().ToString().c_str(),
|
details->symbol().name(), details->module().name());
|
||||||
details->module().name().ToString().c_str());
|
|
||||||
} else {
|
} else {
|
||||||
msg.Attach(prev.name(), "Previous declaration of '%s'"_en_US,
|
msg.Attach(prev.name(), "Previous declaration of '%s'"_en_US, prev.name());
|
||||||
prev.name().ToString().c_str());
|
|
||||||
}
|
}
|
||||||
context().SetError(prev);
|
context().SetError(prev);
|
||||||
}
|
}
|
||||||
|
@ -1491,12 +1487,11 @@ void ScopeHandler::SayDerivedType(
|
||||||
CHECK(typeSymbol != nullptr);
|
CHECK(typeSymbol != nullptr);
|
||||||
Say(name, std::move(msg), name, typeSymbol->name())
|
Say(name, std::move(msg), name, typeSymbol->name())
|
||||||
.Attach(typeSymbol->name(), "Declaration of derived type '%s'"_en_US,
|
.Attach(typeSymbol->name(), "Declaration of derived type '%s'"_en_US,
|
||||||
typeSymbol->name().ToString().c_str());
|
typeSymbol->name());
|
||||||
}
|
}
|
||||||
void ScopeHandler::Say2(const SourceName &name1, MessageFixedText &&msg1,
|
void ScopeHandler::Say2(const SourceName &name1, MessageFixedText &&msg1,
|
||||||
const SourceName &name2, MessageFixedText &&msg2) {
|
const SourceName &name2, MessageFixedText &&msg2) {
|
||||||
Say(name1, std::move(msg1))
|
Say(name1, std::move(msg1)).Attach(name2, std::move(msg2), name2);
|
||||||
.Attach(name2, std::move(msg2), name2.ToString().c_str());
|
|
||||||
}
|
}
|
||||||
void ScopeHandler::Say2(const SourceName &name, MessageFixedText &&msg1,
|
void ScopeHandler::Say2(const SourceName &name, MessageFixedText &&msg1,
|
||||||
Symbol &symbol, MessageFixedText &&msg2) {
|
Symbol &symbol, MessageFixedText &&msg2) {
|
||||||
|
@ -1870,7 +1865,7 @@ void ModuleVisitor::AddUse(
|
||||||
"Cannot use-associate '%s'; it is already declared in this scope"_err_en_US,
|
"Cannot use-associate '%s'; it is already declared in this scope"_err_en_US,
|
||||||
localSymbol.name())
|
localSymbol.name())
|
||||||
.Attach(localSymbol.name(), "Previous declaration of '%s'"_en_US,
|
.Attach(localSymbol.name(), "Previous declaration of '%s'"_en_US,
|
||||||
localSymbol.name().ToString().c_str());
|
localSymbol.name());
|
||||||
} else {
|
} else {
|
||||||
localSymbol.set_details(UseDetails{location, useSymbol});
|
localSymbol.set_details(UseDetails{location, useSymbol});
|
||||||
}
|
}
|
||||||
|
@ -2381,7 +2376,7 @@ bool DeclarationVisitor::CheckUseError(const parser::Name &name) {
|
||||||
Message &msg{Say(name, "Reference to '%s' is ambiguous"_err_en_US)};
|
Message &msg{Say(name, "Reference to '%s' is ambiguous"_err_en_US)};
|
||||||
for (const auto &[location, module] : details->occurrences()) {
|
for (const auto &[location, module] : details->occurrences()) {
|
||||||
msg.Attach(location, "'%s' was use-associated from module '%s'"_en_US,
|
msg.Attach(location, "'%s' was use-associated from module '%s'"_en_US,
|
||||||
name.ToString().data(), module->name().ToString().data());
|
name.source, module->name());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4515,7 +4510,7 @@ void ResolveNamesVisitor::CheckImport(
|
||||||
if (auto *symbol{FindInScope(currScope(), name)}) {
|
if (auto *symbol{FindInScope(currScope(), name)}) {
|
||||||
Say(location, "'%s' from host is not accessible"_err_en_US, name)
|
Say(location, "'%s' from host is not accessible"_err_en_US, name)
|
||||||
.Attach(symbol->name(), "'%s' is hidden by this entity"_en_US,
|
.Attach(symbol->name(), "'%s' is hidden by this entity"_en_US,
|
||||||
symbol->name().ToString().c_str());
|
symbol->name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue