[flang-commits] [flang] a2ac0bb - [flang] Warn for the limit on name length
via flang-commits
flang-commits at lists.llvm.org
Fri May 13 07:44:48 PDT 2022
Author: PeixinQiao
Date: 2022-05-13T22:43:12+08:00
New Revision: a2ac0bb2f141520150c823eb28896f45feb59832
URL: https://github.com/llvm/llvm-project/commit/a2ac0bb2f141520150c823eb28896f45feb59832
DIFF: https://github.com/llvm/llvm-project/commit/a2ac0bb2f141520150c823eb28896f45feb59832.diff
LOG: [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
Added:
Modified:
flang/include/flang/Common/Fortran.h
flang/lib/Semantics/check-declarations.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Common/Fortran.h b/flang/include/flang/Common/Fortran.h
index f0b111a3fec7..dc9bd8bae04d 100644
--- a/flang/include/flang/Common/Fortran.h
+++ b/flang/include/flang/Common/Fortran.h
@@ -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_
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index c92a8dd3429b..632720825205 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -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;
}
More information about the flang-commits
mailing list