[PATCH] D78424: [flang] Added Semantic Checks for 2 Data constraints and fixed the semantic errors in 3 test cases

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 14:57:39 PDT 2020


kiranchandramohan added inline comments.


================
Comment at: flang/lib/Semantics/check-data.cpp:18
       context_.Say(parser::FindSourceLocation(x),
           "Data object must have constant bounds"_err_en_US);
     }
----------------
Nit: The new ones in CheckDesignator have O with caps in 'Object'.


================
Comment at: flang/lib/Semantics/check-data.cpp:38
+          name.source, "Data Object must not be a function result"_err_en_US);
+    } else if (IsAllocatable(*symbol)) {
+      context_.Say(name.source,
----------------
Should this catch the case where the component is not allocatable but the structure is?

```
program simple_alloc
  type t1
    real r
  end type
  type t2
    type(t1), allocatable :: arr(:)
  end type
  type(t2) d
  data d%arr(3)%r/10.0/
end
```


================
Comment at: flang/lib/Semantics/check-data.cpp:44
+          "Data Object must not be accessed by host association"_err_en_US);
+    } else if (IsUseAssociated(*symbol, scope)) {
+      context_.Say(name.source,
----------------
Should this check fire for the data statement in the following program where the type is defined in a module but the variable itself is not?
```
module dt
  type d
    real r
  end type
end module
program test
  use dt
  type(d) :: d1
  data d1%r/2.5/
end program
```


================
Comment at: flang/test/Semantics/data04.f90:1
+! RUN: %B/test/Semantics/test_errors.sh %s %flang %t
+!Testing data constraints : C876, C877
----------------
Can you add some tests with derived types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78424





More information about the llvm-commits mailing list