[flang-commits] [flang] b288b41 - [flang] Enforce C839 (#71239)

via flang-commits flang-commits at lists.llvm.org
Mon Nov 13 14:31:24 PST 2023


Author: Peter Klausler
Date: 2023-11-13T14:31:20-08:00
New Revision: b288b412edbe1a9e6f2cf88672a214f29082e2d3

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

LOG: [flang] Enforce C839 (#71239)

An assumed-rank array may not be a coarray and may not have the VALUE
attribute.

Added: 
    

Modified: 
    flang/lib/Semantics/check-declarations.cpp
    flang/test/Semantics/call14.f90
    flang/test/Semantics/misc-declarations.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 6d69eb187bda089..ce7df5ea7ea13bc 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -564,6 +564,10 @@ void CheckHelper::CheckValue(
           "VALUE attribute may not apply to a type with a coarray ultimate component"_err_en_US);
     }
   }
+  if (evaluate::IsAssumedRank(symbol)) {
+    messages_.Say(
+        "VALUE attribute may not apply to an assumed-rank array"_err_en_US);
+  }
 }
 
 void CheckHelper::CheckAssumedTypeEntity( // C709
@@ -657,6 +661,10 @@ void CheckHelper::CheckObjectEntity(
           "Coarray '%s' may not have type TEAM_TYPE, C_PTR, or C_FUNPTR"_err_en_US,
           symbol.name());
     }
+    if (evaluate::IsAssumedRank(symbol)) {
+      messages_.Say("Coarray '%s' may not be an assumed-rank array"_err_en_US,
+          symbol.name());
+    }
   }
   if (details.isDummy()) {
     if (IsIntentOut(symbol)) {

diff  --git a/flang/test/Semantics/call14.f90 b/flang/test/Semantics/call14.f90
index 477c22b02f2cdb2..da273050b6f3a94 100644
--- a/flang/test/Semantics/call14.f90
+++ b/flang/test/Semantics/call14.f90
@@ -7,7 +7,7 @@ module m
   end type
  contains
   !ERROR: VALUE attribute may apply only to a dummy data object
-  subroutine C863(notData,assumedSize,coarray,coarrayComponent)
+  subroutine C863(notData,assumedSize,coarray,coarrayComponent,assumedRank)
     external :: notData
     !ERROR: VALUE attribute may apply only to a dummy argument
     real, value :: notADummy
@@ -18,6 +18,8 @@ subroutine C863(notData,assumedSize,coarray,coarrayComponent)
     real, value :: coarray[*]
     !ERROR: VALUE attribute may not apply to a type with a coarray ultimate component
     type(hasCoarray), value :: coarrayComponent
+    !ERROR: VALUE attribute may not apply to an assumed-rank array
+    real, value :: assumedRank(..)
   end subroutine
   subroutine C864(allocatable, inout, out, pointer, volatile)
     !ERROR: VALUE attribute may not apply to an ALLOCATABLE

diff  --git a/flang/test/Semantics/misc-declarations.f90 b/flang/test/Semantics/misc-declarations.f90
index ca5f6f7ccd976ce..74b71c0847f59a1 100644
--- a/flang/test/Semantics/misc-declarations.f90
+++ b/flang/test/Semantics/misc-declarations.f90
@@ -38,4 +38,8 @@ subroutine C868(coarray,coarrayComponent)
       volatile :: coarrayComponent
     end block
   end subroutine
+  subroutine C839(x)
+    !ERROR: Coarray 'x' may not be an assumed-rank array
+    real, intent(in) :: x(..)[*]
+  end
 end module


        


More information about the flang-commits mailing list