[flang] Warn for the limit on name length

As fortran 2018 C601, the maximum length of a name is 63 characters.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D125371
This commit is contained in:
PeixinQiao
2022-05-13 22:43:12 +08:00
parent 0c00dbb975
commit a2ac0bb2f1
2 changed files with 9 additions and 0 deletions

View File

@@ -72,5 +72,8 @@ using Label = std::uint64_t;
// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
static constexpr int maxRank{15};
// Fortran names may have up to 63 characters (See Fortran 2018 C601).
static constexpr int maxNameLen{63};
} // namespace Fortran::common
#endif // FORTRAN_COMMON_FORTRAN_H_

View File

@@ -198,6 +198,12 @@ void CheckHelper::Check(
}
void CheckHelper::Check(const Symbol &symbol) {
if (symbol.name().size() > common::maxNameLen) {
messages_.Say(symbol.name(),
"%s has length %d, which is greater than the maximum name length "
"%d"_port_en_US,
symbol.name(), symbol.name().size(), common::maxNameLen);
}
if (context_.HasError(symbol)) {
return;
}