[flang-commits] [flang] 90c4eda - [flang] Dial some errors down to warnings for ASSOCIATED()
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Jul 25 11:06:38 PDT 2022
Author: Peter Klausler
Date: 2022-07-25T11:06:30-07:00
New Revision: 90c4eda3d29a9d08744891b941a30f1be61dbe46
URL: https://github.com/llvm/llvm-project/commit/90c4eda3d29a9d08744891b941a30f1be61dbe46
DIFF: https://github.com/llvm/llvm-project/commit/90c4eda3d29a9d08744891b941a30f1be61dbe46.diff
LOG: [flang] Dial some errors down to warnings for ASSOCIATED()
When a procedure pointer is associated with a procedure target, f18
will emit hard error messages if the pointer is incompatible with the
target in a way that would cause the program to not work if the
procedure pointer were actually called. However, in the context of
the ASSOCIATED() intrinsic, the compiler should not consider a query
to be a compilation-time error if the pointer and the target are
incompatible. The standard gives us sufficient wiggle room here
to treat these cases as warnings.
Attempts to use ASSOCIATED to test whether a procedure pointer is
associated with a data object, or vice versa, remain errors.
Differential Revision: https://reviews.llvm.org/D130384
Added:
Modified:
flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/associated.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index eb94f6eebaf9d..8638b1dc6d1f3 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2262,6 +2262,7 @@ static bool CheckAssociated(SpecificCall &call, FoldingContext &context) {
if (std::optional<parser::MessageFixedText> msg{
CheckProcCompatibility(
isCall, pointerProc, &*targetProc, whyNot)}) {
+ msg->set_severity(parser::Severity::Warning);
AttachDeclaration(
context.messages().Say(std::move(*msg),
"pointer '" + pointerSymbol->name().ToString() +
diff --git a/flang/test/Semantics/associated.f90 b/flang/test/Semantics/associated.f90
index 0bca7edf8e2fb..6a4d1af7316b6 100644
--- a/flang/test/Semantics/associated.f90
+++ b/flang/test/Semantics/associated.f90
@@ -137,7 +137,7 @@ subroutine test()
lVar = associated(intprocPointer1, intVar)
!ERROR: Procedure pointer 'intprocpointer1' associated with incompatible procedure designator 'elementalproc': incompatible dummy argument #1: incompatible dummy data object attributes
intProcPointer1 => elementalProc
- !ERROR: Procedure pointer 'intprocpointer1' associated with incompatible procedure designator 'elementalproc': incompatible dummy argument #1: incompatible dummy data object attributes
+ !WARNING: Procedure pointer 'intprocpointer1' associated with incompatible procedure designator 'elementalproc': incompatible dummy argument #1: incompatible dummy data object attributes
lvar = associated(intProcPointer1, elementalProc)
!ERROR: POINTER= argument 'intpointervar1' is an object pointer but the TARGET= argument 'intfunc' is a procedure designator
lvar = associated (intPointerVar1, intFunc)
@@ -149,33 +149,33 @@ subroutine test()
lvar = associated (intProcPointer1, targetIntVar1)
!ERROR: Procedure pointer 'intprocpointer1' associated with result of reference to function 'null' that is an incompatible procedure pointer: function results have incompatible types: INTEGER(4) vs REAL(4)
intProcPointer1 => null(mold=realProcPointer1)
- !ERROR: Procedure pointer 'intprocpointer1' associated with result of reference to function 'null()' that is an incompatible procedure pointer: function results have incompatible types: INTEGER(4) vs REAL(4)
+ !WARNING: Procedure pointer 'intprocpointer1' associated with result of reference to function 'null()' that is an incompatible procedure pointer: function results have incompatible types: INTEGER(4) vs REAL(4)
lvar = associated(intProcPointer1, null(mold=realProcPointer1))
!ERROR: PURE procedure pointer 'purefuncpointer' may not be associated with non-PURE procedure designator 'intproc'
pureFuncPointer => intProc
- !ERROR: PURE procedure pointer 'purefuncpointer' may not be associated with non-PURE procedure designator 'intproc'
+ !WARNING: PURE procedure pointer 'purefuncpointer' may not be associated with non-PURE procedure designator 'intproc'
lvar = associated(pureFuncPointer, intProc)
!ERROR: Procedure pointer 'realprocpointer1' associated with incompatible procedure designator 'intproc': function results have incompatible types: REAL(4) vs INTEGER(4)
realProcPointer1 => intProc
- !ERROR: Procedure pointer 'realprocpointer1' associated with incompatible procedure designator 'intproc': function results have incompatible types: REAL(4) vs INTEGER(4)
+ !WARNING: Procedure pointer 'realprocpointer1' associated with incompatible procedure designator 'intproc': function results have incompatible types: REAL(4) vs INTEGER(4)
lvar = associated(realProcPointer1, intProc)
subProcPointer => externalProc ! OK to associate a procedure pointer with an explicit interface to a procedure with an implicit interface
lvar = associated(subProcPointer, externalProc) ! OK to associate a procedure pointer with an explicit interface to a procedure with an implicit interface
!ERROR: Subroutine pointer 'subprocpointer' may not be associated with function designator 'intproc'
subProcPointer => intProc
- !ERROR: Subroutine pointer 'subprocpointer' may not be associated with function designator 'intproc'
+ !WARNING: Subroutine pointer 'subprocpointer' may not be associated with function designator 'intproc'
lvar = associated(subProcPointer, intProc)
!ERROR: Function pointer 'intprocpointer1' may not be associated with subroutine designator 'subproc'
intProcPointer1 => subProc
- !ERROR: Function pointer 'intprocpointer1' may not be associated with subroutine designator 'subproc'
+ !WARNING: Function pointer 'intprocpointer1' may not be associated with subroutine designator 'subproc'
lvar = associated(intProcPointer1, subProc)
implicitProcPointer => subr ! OK for an implicit point to point to an explicit proc
lvar = associated(implicitProcPointer, subr) ! OK
- !ERROR: Procedure pointer 'implicitprocpointer' with implicit interface may not be associated with procedure designator 'subrcannotbecalledfromimplicit' with explicit interface that cannot be called via an implicit interface
+ !WARNING: Procedure pointer 'implicitprocpointer' with implicit interface may not be associated with procedure designator 'subrcannotbecalledfromimplicit' with explicit interface that cannot be called via an implicit interface
lvar = associated(implicitProcPointer, subrCannotBeCalledFromImplicit)
!ERROR: Procedure pointer 'cannotbecalledfromimplicitpointer' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
cannotBeCalledfromImplicitPointer => externalProc
- !ERROR: Procedure pointer 'cannotbecalledfromimplicitpointer' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
+ !WARNING: Procedure pointer 'cannotbecalledfromimplicitpointer' with explicit interface that cannot be called via an implicit interface cannot be associated with procedure designator with an implicit interface
lvar = associated(cannotBeCalledfromImplicitPointer, externalProc)
end subroutine test
end subroutine assoc
More information about the flang-commits
mailing list