Skip to content

Commit a2ac0bb

Browse files
committed
[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
1 parent 0c00dbb commit a2ac0bb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

flang/include/flang/Common/Fortran.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,8 @@ using Label = std::uint64_t;
7272

7373
// Fortran arrays may have up to 15 dimensions (See Fortran 2018 section 5.4.6).
7474
static constexpr int maxRank{15};
75+
76+
// Fortran names may have up to 63 characters (See Fortran 2018 C601).
77+
static constexpr int maxNameLen{63};
7578
} // namespace Fortran::common
7679
#endif // FORTRAN_COMMON_FORTRAN_H_

flang/lib/Semantics/check-declarations.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ void CheckHelper::Check(
198198
}
199199

200200
void CheckHelper::Check(const Symbol &symbol) {
201+
if (symbol.name().size() > common::maxNameLen) {
202+
messages_.Say(symbol.name(),
203+
"%s has length %d, which is greater than the maximum name length "
204+
"%d"_port_en_US,
205+
symbol.name(), symbol.name().size(), common::maxNameLen);
206+
}
201207
if (context_.HasError(symbol)) {
202208
return;
203209
}

0 commit comments

Comments
 (0)