#include "message.h"
#include "char-set.h"
-#include "parse-tree.h"
#include "../common/idioms.h"
#include <algorithm>
#include <cstdarg>
return Convert(x.ToString());
}
-const char *MessageFormattedText::Convert(const Name &n) {
- return Convert(n.source);
-}
-
-const char *MessageFormattedText::Convert(Name &n) { return Convert(n.source); }
-
-const char *MessageFormattedText::Convert(Name &&n) {
- return Convert(n.source);
-}
-
std::string MessageExpectedText::ToString() const {
return std::visit(
common::visitors{
namespace Fortran::parser {
-struct Name;
-
// Use "..."_err_en_US and "..."_en_US literals to define the static
// text and fatality of a message.
class MessageFixedText {
// The construction of a MessageFormattedText uses a MessageFixedText
// as a vsnprintf() formatting string that is applied to the
-// following arguments. CharBlock and std::string argument values are
-// also supported; they are automatically converted into char pointers
-// that are suitable for '%s' formatting.
+// following arguments. CharBlock and std::string argument
+// values are also supported; they are automatically converted into
+// char pointers that are suitable for '%s' formatting.
class MessageFormattedText {
public:
template<typename... A>
private:
void Format(const MessageFixedText *text, ...);
- template<typename A> A Convert(A &x) { return x; }
+
+ template<typename A> A Convert(const A &x) {
+ static_assert(!std::is_class_v<std::decay_t<A>>);
+ return x;
+ }
+ template<typename A> A Convert(A &x) {
+ static_assert(!std::is_class_v<std::decay_t<A>>);
+ return x;
+ }
template<typename A> common::IfNoLvalue<A, A> Convert(A &&x) {
+ static_assert(!std::is_class_v<std::decay_t<A>>);
return std::move(x);
}
const char *Convert(const std::string &);
const char *Convert(const CharBlock &);
const char *Convert(CharBlock &);
const char *Convert(CharBlock &&);
- const char *Convert(const Name &);
- const char *Convert(Name &);
- const char *Convert(Name &&);
bool isFatal_{false};
std::string string_;
// Check that name has been resolved to a symbol
void RewriteMutator::Post(parser::Name &name) {
if (name.symbol == nullptr && errorOnUnresolvedName_) {
- messages_.Say(
- name.source, "Internal: no symbol found for '%s'"_err_en_US, name);
+ messages_.Say(name.source, "Internal: no symbol found for '%s'"_err_en_US,
+ name.source);
}
}