[flang-commits] [flang] 78da80e - [flang] Restore C702 check for ProcEntity symbols
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Dec 2 12:06:58 PST 2022
Author: Peter Klausler
Date: 2022-12-02T12:06:49-08:00
New Revision: 78da80e2ef6e0531ebdc53f240d87187f9191f3f
URL: https://github.com/llvm/llvm-project/commit/78da80e2ef6e0531ebdc53f240d87187f9191f3f
DIFF: https://github.com/llvm/llvm-project/commit/78da80e2ef6e0531ebdc53f240d87187f9191f3f.diff
LOG: [flang] Restore C702 check for ProcEntity symbols
A recent change moved some checking code from name resolution into
declaration checking, and inadvertently disabled C702 checking for
procedure entities. Fix.
Differential Revision: https://reviews.llvm.org/D139043
Added:
Modified:
flang/lib/Semantics/check-declarations.cpp
flang/test/Semantics/resolve69.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 11367c4a61f20..22588ce3e7f4f 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -88,6 +88,7 @@ class CheckHelper {
void CheckGenericOps(const Scope &);
bool CheckConflicting(const Symbol &, Attr, Attr);
void WarnMissingFinal(const Symbol &);
+ void CheckSymbolType(const Symbol &); // C702
bool InPure() const {
return innermostSymbol_ && IsPureProcedure(*innermostSymbol_);
}
@@ -494,15 +495,7 @@ void CheckHelper::CheckAssumedTypeEntity( // C709
void CheckHelper::CheckObjectEntity(
const Symbol &symbol, const ObjectEntityDetails &details) {
- if (!IsAllocatableOrPointer(symbol)) { // C702
- if (auto dyType{evaluate::DynamicType::From(symbol)}) {
- if (dyType->HasDeferredTypeParameter()) {
- messages_.Say(
- "'%s' has a type %s with a deferred type parameter but is neither an allocatable or a pointer"_err_en_US,
- symbol.name(), dyType->AsFortran());
- }
- }
- }
+ CheckSymbolType(symbol);
CheckArraySpec(symbol, details.shape());
Check(details.shape());
Check(details.coshape());
@@ -801,6 +794,7 @@ void CheckHelper::CheckArraySpec(
void CheckHelper::CheckProcEntity(
const Symbol &symbol, const ProcEntityDetails &details) {
+ CheckSymbolType(symbol);
if (details.isDummy()) {
if (!symbol.attrs().test(Attr::POINTER) && // C843
(symbol.attrs().test(Attr::INTENT_IN) ||
@@ -2337,6 +2331,18 @@ void CheckHelper::CheckDefinedIoProc(const Symbol &symbol,
}
}
+void CheckHelper::CheckSymbolType(const Symbol &symbol) {
+ if (!IsAllocatableOrPointer(symbol)) { // C702
+ if (auto dyType{evaluate::DynamicType::From(symbol)}) {
+ if (dyType->HasDeferredTypeParameter()) {
+ messages_.Say(
+ "'%s' has a type %s with a deferred type parameter but is neither an allocatable or a pointer"_err_en_US,
+ symbol.name(), dyType->AsFortran());
+ }
+ }
+ }
+}
+
void SubprogramMatchHelper::Check(
const Symbol &symbol1, const Symbol &symbol2) {
const auto details1{symbol1.get<SubprogramDetails>()};
diff --git a/flang/test/Semantics/resolve69.f90 b/flang/test/Semantics/resolve69.f90
index 0edc91ab6cf1d..4db277dfe5c7f 100644
--- a/flang/test/Semantics/resolve69.f90
+++ b/flang/test/Semantics/resolve69.f90
@@ -26,6 +26,16 @@ subroutine s1()
character(:) :: colonString2
!OK because of the allocatable attribute
character(:), allocatable :: colonString3
+!ERROR: 'foo1' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable or a pointer
+ character(:), external :: foo1
+!ERROR: 'foo2' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable or a pointer
+ procedure(character(:)) :: foo2
+ interface
+ function foo3()
+!ERROR: 'foo3' has a type CHARACTER(KIND=1,LEN=:) with a deferred type parameter but is neither an allocatable or a pointer
+ character(:) foo3
+ end function
+ end interface
!ERROR: Must have INTEGER type, but is REAL(4)
character(3.5) :: badParamValue
@@ -75,6 +85,8 @@ function f4
implicit character(:)(f)
end function
+!Not errors.
+
Program d5
Type string(maxlen)
Integer,Kind :: maxlen
@@ -85,7 +97,6 @@ Program d5
Print *,Trim(line%value)
End Program
-!Not errors.
subroutine outer
integer n
contains
More information about the flang-commits
mailing list