[flang-commits] [PATCH] D143780: [flang] Catch misuse of a procedure designator as an output item

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Sun Feb 12 16:45:19 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa128bb21ee3: [flang] Catch misuse of a procedure designator as an output item (authored by klausler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143780

Files:
  flang/lib/Semantics/check-io.cpp
  flang/lib/Semantics/expression.cpp
  flang/test/Semantics/io04.f90


Index: flang/test/Semantics/io04.f90
===================================================================
--- flang/test/Semantics/io04.f90
+++ flang/test/Semantics/io04.f90
@@ -12,6 +12,8 @@
   integer, pointer :: a(:)
   integer, parameter :: const_id = 66666
   procedure(), pointer :: procptr
+  external external
+  intrinsic acos
 
   namelist /nnn/ nn1, nn2
 
@@ -134,8 +136,12 @@
 
   write(*, '(X)')
 
-  !ERROR: Output item must not be a procedure pointer
-  print*, n1, procptr, n2
+  !ERROR: Output item must not be a procedure
+  print*, procptr
+  !ERROR: Output item must not be a procedure
+  print*, acos
+  !ERROR: Output item must not be a procedure
+  print*, external
 
 1 format (A)
 9 continue
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -566,10 +566,10 @@
     std::optional<DataRef> dataRef{ExtractDataRef(std::move(result))};
     if (!dataRef) {
       dataRef = ExtractDataRef(std::move(result), /*intoSubstring=*/true);
-      if (!dataRef) {
-        dataRef = ExtractDataRef(std::move(result),
-            /*intoSubstring=*/false, /*intoComplexPart=*/true);
-      }
+    }
+    if (!dataRef) {
+      dataRef = ExtractDataRef(std::move(result),
+          /*intoSubstring=*/false, /*intoComplexPart=*/true);
     }
     if (dataRef && !CheckDataRef(*dataRef)) {
       result.reset();
Index: flang/lib/Semantics/check-io.cpp
===================================================================
--- flang/lib/Semantics/check-io.cpp
+++ flang/lib/Semantics/check-io.cpp
@@ -613,11 +613,9 @@
       if (evaluate::IsBOZLiteral(*expr)) {
         context_.Say(parser::FindSourceLocation(*x), // C7109
             "Output item must not be a BOZ literal constant"_err_en_US);
-      }
-      const Symbol *last{GetLastSymbol(*expr)};
-      if (last && IsProcedurePointer(*last)) {
+      } else if (IsProcedure(*expr)) {
         context_.Say(parser::FindSourceLocation(*x),
-            "Output item must not be a procedure pointer"_err_en_US); // C1233
+            "Output item must not be a procedure"_err_en_US); // C1233
       }
       CheckForBadIoType(*expr,
           flags_.test(Flag::FmtOrNml)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143780.496814.patch
Type: text/x-patch
Size: 2280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230213/bd7f32f8/attachment-0001.bin>


More information about the flang-commits mailing list