Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorPeixinQiao <qiaopeixin@huawei.com>2022-05-13 17:43:12 +0300
committerPeixinQiao <qiaopeixin@huawei.com>2022-05-13 17:43:12 +0300
commita2ac0bb2f141520150c823eb28896f45feb59832 (patch)
treeaf06be0c8d4dfa3da708102f13cd8bbd2f4e5453 /flang
parent0c00dbb97557e6ff177beeab3b2ea583b3eac482 (diff)
[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
Diffstat (limited to 'flang')
-rw-r--r--flang/include/flang/Common/Fortran.h3
-rw-r--r--flang/lib/Semantics/check-declarations.cpp6
2 files changed, 9 insertions, 0 deletions
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;
}