[flang-commits] [flang] ebf3dbb - Revert "[flang] Add co_sum to the list of intrinsics and update test"

Katherine Rasmussen via flang-commits flang-commits at lists.llvm.org
Thu Jul 14 14:46:02 PDT 2022


Author: Katherine Rasmussen
Date: 2022-07-14T14:44:34-07:00
New Revision: ebf3dbbe15431f93cc837d1b30c4b0e377ffdf31

URL: https://github.com/llvm/llvm-project/commit/ebf3dbbe15431f93cc837d1b30c4b0e377ffdf31
DIFF: https://github.com/llvm/llvm-project/commit/ebf3dbbe15431f93cc837d1b30c4b0e377ffdf31.diff

LOG: Revert "[flang] Add co_sum to the list of intrinsics and update test"

This reverts commit d2460d90080f2ff8564ceed745998f821544ec98.

Reverting this commit because after pushing to main it caused
unexpected test failures.

Added: 
    

Modified: 
    flang/lib/Evaluate/intrinsics.cpp
    flang/test/Semantics/collectives01.f90

Removed: 
    flang/test/Semantics/move_alloc.f90


################################################################################
diff  --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index eb8cdd1d962f9..d9a7084c52098 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1073,16 +1073,6 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
 
 static const IntrinsicInterface intrinsicSubroutine[]{
     {"abort", {}, {}, Rank::elemental, IntrinsicClass::impureSubroutine},
-    {"co_sum",
-        {{"a", AnyNumeric, Rank::anyOrAssumedRank, Optionality::required,
-             common::Intent::InOut},
-            {"result_image", AnyInt, Rank::scalar, Optionality::optional,
-                common::Intent::In},
-            {"stat", AnyInt, Rank::scalar, Optionality::optional,
-                common::Intent::Out},
-            {"errmsg", DefaultChar, Rank::scalar, Optionality::optional,
-                common::Intent::InOut}},
-        {}, Rank::elemental, IntrinsicClass::collectiveSubroutine},
     {"cpu_time",
         {{"time", AnyReal, Rank::scalar, Optionality::required,
             common::Intent::Out}},
@@ -2374,26 +2364,6 @@ static bool CheckForNonPositiveValues(FoldingContext &context,
   return ok;
 }
 
-static bool CheckForCoindexedObjects(SpecificCall &call,
-    FoldingContext &context, const std::vector<std::string> &dummyNames) {
-  bool ok{true};
-  CHECK(call.arguments.size() == dummyNames.size());
-  for (std::size_t j{0}; j < call.arguments.size(); ++j) {
-    if (dummyNames[j] != "result_image") {
-      const auto &arg{call.arguments[j]};
-      if (const auto *expr{arg->UnwrapExpr()}) {
-        if (ExtractCoarrayRef(*expr)) {
-          ok = false;
-          context.messages().Say(arg->sourceLocation(),
-              "'%s' argument to '%s' may not be a coindexed object"_err_en_US,
-              dummyNames[j], call.specificIntrinsic.name);
-        }
-      }
-    }
-  }
-  return ok;
-}
-
 // Applies any semantic checks peculiar to an intrinsic.
 static bool ApplySpecificChecks(SpecificCall &call, FoldingContext &context) {
   bool ok{true};
@@ -2412,9 +2382,6 @@ static bool ApplySpecificChecks(SpecificCall &call, FoldingContext &context) {
     }
   } else if (name == "associated") {
     return CheckAssociated(call, context);
-  } else if (name == "co_sum") {
-    return CheckForCoindexedObjects(call, context,
-        std::vector<std::string>{"a", "result_image", "stat", "errmsg"});
   } else if (name == "image_status") {
     if (const auto &arg{call.arguments[0]}) {
       ok = CheckForNonPositiveValues(context, *arg, name, "image");
@@ -2446,9 +2413,6 @@ static bool ApplySpecificChecks(SpecificCall &call, FoldingContext &context) {
           arg ? arg->sourceLocation() : context.messages().at(),
           "Argument of LOC() must be an object or procedure"_err_en_US);
     }
-  } else if (name == "move_alloc") {
-    return CheckForCoindexedObjects(call, context,
-        std::vector<std::string>{"from", "to", "stat", "errmsg"});
   } else if (name == "present") {
     const auto &arg{call.arguments[0]};
     if (arg) {
@@ -2596,7 +2560,6 @@ std::optional<SpecificCall> IntrinsicProcTable::Implementation::Probe(
     for (auto iter{subrRange.first}; iter != subrRange.second; ++iter) {
       if (auto specificCall{iter->second->Match(
               call, defaults_, arguments, context, builtinsScope_)}) {
-        ApplySpecificChecks(*specificCall, context);
         return specificCall;
       }
     }

diff  --git a/flang/test/Semantics/collectives01.f90 b/flang/test/Semantics/collectives01.f90
index 3eb9aa92ea5da..e07a93fd3e964 100644
--- a/flang/test/Semantics/collectives01.f90
+++ b/flang/test/Semantics/collectives01.f90
@@ -1,11 +1,13 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
+! XFAIL: *
 ! This test checks for semantic errors in co_sum subroutine calls based on
 ! the co_reduce interface defined in section 16.9.50 of the Fortran 2018 standard.
+! To Do: add co_sum to the list of intrinsics
 
 program test_co_sum
   implicit none
 
-  integer i, status, integer_array(1), coindexed_integer[*], coindexed_result_image[*]
+  integer i, status, integer_array(1), coindexed_integer[*]
   complex c, complex_array(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) 
   double precision d, double_precision_array(1)
   real r, real_array(1), coindexed_real[*]
@@ -42,22 +44,15 @@ program test_co_sum
   call co_sum(a=i, result_image=1                             ) 
   call co_sum(a=i,                 stat=status                )
   call co_sum(a=i,                              errmsg=message) 
-  call co_sum(a=i, result_image=coindexed_result_image[1])
 
   ! no optional arguments present
   call co_sum(a=i                                             ) 
 
   !___ non-standard-conforming calls ___
 
-  !ERROR: missing mandatory 'a=' argument
-  call co_sum()
-
   !ERROR: missing mandatory 'a=' argument
   call co_sum(result_image=1, stat=status, errmsg=message)
 
-  !ERROR: repeated keyword argument to intrinsic 'co_sum'
-  call co_sum(a=i, a=c)
-
   ! argument 'a' shall be of numeric type
   !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'
   call co_sum(bool)
@@ -66,7 +61,8 @@ program test_co_sum
   !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'a=' must be definable
   call co_sum(a=1+1)
   
-  !ERROR: 'a' argument to 'co_sum' may not be a coindexed object
+  ! argument 'a' shall not be a coindexed object
+  !ERROR: to be determined
   call co_sum(a=coindexed_real[1])
   
   ! 'result_image' argument shall be a integer
@@ -81,11 +77,9 @@ program test_co_sum
   !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' must be definable
   call co_sum(a=i, result_image=1, stat=1+1, errmsg=message)
 
-  !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object
+  ! 'stat' argument shall be noncoindexed
+  !ERROR: to be determined
   call co_sum(d, stat=coindexed_integer[1])
-
-  !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object
-  call co_sum(stat=coindexed_integer[1], a=d)
  
   ! 'stat' argument shall be an integer
   !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
@@ -99,27 +93,24 @@ program test_co_sum
   !ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'errmsg=' must be definable
   call co_sum(a=i, result_image=1, stat=status, errmsg='c')
   
-  !ERROR: 'errmsg' argument to 'co_sum' may not be a coindexed object
+  ! 'errmsg' argument shall be noncoindexed
+  !ERROR: to be determined
   call co_sum(c, errmsg=coindexed_character[1])
 
   ! 'errmsg' argument shall be a character
-  !ERROR: Actual argument for 'errmsg=' has bad type 'INTEGER(4)'
+  !ERROR: to be determined
   call co_sum(c, errmsg=i)
  
   ! 'errmsg' argument shall be character scalar
   !ERROR: 'errmsg=' argument has unacceptable rank 1
   call co_sum(d, errmsg=character_array)
  
+  ! the error is seen as too many arguments to the co_sum() call
   !ERROR: too many actual arguments for intrinsic 'co_sum'
   call co_sum(r, result_image=1, stat=status, errmsg=message, 3.4)
   
   ! keyword argument with incorrect name
   !ERROR: unknown keyword argument to intrinsic 'co_sum'
   call co_sum(fake=3.4)
-
-  !ERROR: 'a' argument to 'co_sum' may not be a coindexed object
-  !ERROR: 'errmsg' argument to 'co_sum' may not be a coindexed object
-  !ERROR: 'stat' argument to 'co_sum' may not be a coindexed object
-  call co_sum(result_image=coindexed_result_image[1], a=coindexed_real[1], errmsg=coindexed_character[1], stat=coindexed_integer[1])
   
 end program test_co_sum

diff  --git a/flang/test/Semantics/move_alloc.f90 b/flang/test/Semantics/move_alloc.f90
deleted file mode 100644
index 41e38c6761294..0000000000000
--- a/flang/test/Semantics/move_alloc.f90
+++ /dev/null
@@ -1,46 +0,0 @@
-! RUN: %python %S/test_errors.py %s %flang_fc1
-! Check for semantic errors in move_alloc() subroutine calls
-program main
-  integer, allocatable :: a(:)[:], b(:)[:], c(:)[:], d(:)[:]
-  !ERROR: 'e' is an ALLOCATABLE coarray and must have a deferred coshape
-  integer, allocatable :: e(:)[*]
-  integer status, coindexed_status[*]
-  character(len=1) message, coindexed_message[*]
-
-  ! standards conforming
-  allocate(a(3)[*])
-  a = [ 1, 2, 3 ]
-  call move_alloc(a, b, status, message)
-
-  allocate(c(3)[*])
-  c = [ 1, 2, 3 ]
-
-  !ERROR: too many actual arguments for intrinsic 'move_alloc'
-  call move_alloc(a, b, status, message, 1)
-
-  ! standards non-conforming
-  !ERROR: 'from' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c[1], d)
-
-  !ERROR: 'to' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d[1])
-
-  !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, coindexed_status[1])
-
-  !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, status, coindexed_message[1])
-
-  !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, errmsg=coindexed_message[1])
-
-  !ERROR: 'errmsg' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, errmsg=coindexed_message[1], stat=status)
-
-  !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, stat=coindexed_status[1])
-
-  !ERROR: 'stat' argument to 'move_alloc' may not be a coindexed object
-  call move_alloc(c, d, errmsg=message, stat=coindexed_status[1])
-
-end program main


        


More information about the flang-commits mailing list