[PATCH] D79851: [Flang] Semantics for SELECT TYPE

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 8 16:39:52 PDT 2020


kiranchandramohan added inline comments.


================
Comment at: flang/lib/Semantics/check-select-type.cpp:139
+        // From dynamicTypespec  -> derivedtypespec
+        const auto &selDerivedTypeSpec{selectorType_.GetDerivedTypeSpec()};
+        if (!(derived == selDerivedTypeSpec) &&
----------------
Is it guaranteed that selectorType will be derived here? Bad code can have a selector which is not derived.


================
Comment at: flang/lib/Semantics/resolve-names.cpp:5143-5145
     // This isn't a name in the current scope, it is in each TypeGuardStmt
     MakePlaceholder(*name, MiscDetails::Kind::SelectTypeAssociateName);
     association.name = &*name;
----------------
The polymorphic selector check should happen here also to catch cases like the following.

```
program test
  integer :: x
  select type (a => x)
  type is (integer)
    print *,'integer ',a
  end select
end program
```




================
Comment at: flang/test/Semantics/selecttype02.f90:23-37
+        use m1
+        shape_lim_polymorphic => rect_obj
+        label : select type (shape_lim_polymorphic)
+        end select label
+
+        label1 : select type (shape_lim_polymorphic)
+        !ERROR: SELECT TYPE construct name required but missing
----------------
try to use same number of spaces for alignment.


================
Comment at: flang/test/Semantics/selecttype02.f90:40-55
+        use m1
+        shape_lim_polymorphic => rect_obj
+!type-guard-stmt realted checks
+	label : select type (shape_lim_polymorphic)
+		type is (shape) label
+        end select label
+
----------------
alignment


================
Comment at: flang/test/Semantics/selecttype03.f90:17-23
+!vector subscript related
+            class(t1),DIMENSION(:,:),allocatable::array1
+            class(t2),DIMENSION(:,:),allocatable::array2
+	    integer, dimension(2) :: V
+	    V = (/ 1,2 /)
+            allocate(array1(3,3))
+            allocate(array2(3,3))
----------------
Alignment


================
Comment at: flang/test/Semantics/selecttype03.f90:59-66
+            select type(b =>  foo(1) )
+                    type is (t1)
+!ERROR: Left-hand side of assignment is not modifiable
+                        b%i = 1 !VDC
+                    type is (t2)
+!ERROR: Actual argument associated with INTENT(IN OUT) dummy argument 'z=' must be definable
+                        call sub_with_in_and_inout_param_vector(b,b) !VDC
----------------
Alignment


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

https://reviews.llvm.org/D79851





More information about the llvm-commits mailing list