[flang-commits] [PATCH] D139127: [flang] Document and warn about an extension

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sat Dec 3 11:10:17 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGfee041f69de0: [flang] Document and warn about an extension (authored by klausler).

Changed prior to commit:
  https://reviews.llvm.org/D139127?vs=479346&id=479854#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139127/new/

https://reviews.llvm.org/D139127

Files:
  flang/docs/Extensions.md
  flang/lib/Semantics/check-call.cpp
  flang/lib/Semantics/pointer-assignment.cpp
  flang/test/Semantics/bindings03.f90


Index: flang/test/Semantics/bindings03.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/bindings03.f90
@@ -0,0 +1,26 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror
+! Confirm a portability warning on use of a procedure binding apart from a call
+module m
+  type t
+   contains
+    procedure :: sub
+  end type
+ contains
+  subroutine sub(x)
+    class(t), intent(in) :: x
+  end subroutine
+end module
+
+program test
+  use m
+  procedure(sub), pointer :: p
+  type(t) x
+  !PORTABILITY: Procedure binding 'sub' used as target of a pointer assignment
+  p => x%sub
+  !PORTABILITY: Procedure binding 'sub' passed as an actual argument
+  call sub2(x%sub)
+ contains
+  subroutine sub2(s)
+    procedure(sub) s
+  end subroutine
+end
Index: flang/lib/Semantics/pointer-assignment.cpp
===================================================================
--- flang/lib/Semantics/pointer-assignment.cpp
+++ flang/lib/Semantics/pointer-assignment.cpp
@@ -307,6 +307,10 @@
             symbol->name());
         return false;
       }
+    } else if (symbol->has<ProcBindingDetails>()) {
+      evaluate::SayWithDeclaration(context_.messages(), *symbol,
+          "Procedure binding '%s' used as target of a pointer assignment"_port_en_US,
+          symbol->name());
     }
   }
   if (auto chars{Procedure::Characterize(d, context_)}) {
Index: flang/lib/Semantics/check-call.cpp
===================================================================
--- flang/lib/Semantics/check-call.cpp
+++ flang/lib/Semantics/check-call.cpp
@@ -599,6 +599,10 @@
               argProcSymbol->name());
           return;
         }
+      } else if (argProcSymbol->has<ProcBindingDetails>()) {
+        evaluate::SayWithDeclaration(messages, *argProcSymbol,
+            "Procedure binding '%s' passed as an actual argument"_port_en_US,
+            argProcSymbol->name());
       }
     }
     if (auto argChars{characteristics::DummyArgument::FromActual(
Index: flang/docs/Extensions.md
===================================================================
--- flang/docs/Extensions.md
+++ flang/docs/Extensions.md
@@ -247,6 +247,9 @@
   if a binding has renaming with "=> proc".
   The colons are not necessary for an unambiguous parse, C768
   notwithstanding.
+* A type-bound procedure binding can be passed as an actual
+  argument corresponding to a dummy procedure and can be used as
+  the target of a procedure pointer assignment statement.
 
 ### Extensions supported when enabled by options
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139127.479854.patch
Type: text/x-patch
Size: 2560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221203/54f59933/attachment.bin>


More information about the flang-commits mailing list