This is an archive of the discontinued LLVM Phabricator instance.

[flang]Fix for PR47339
ClosedPublic

Authored by inderjeet-hcl on Sep 2 2020, 11:10 PM.

Details

Reviewers
flang-commits
PeteSteinfeld
sscalpone
jdoerfert
DavidTruby
klausler
Group Reviewers
Restricted Project
Summary

Issue is raised as PR 47339.
Following test case should generate compile time error for invalid selector at line #4 and #9 :

R1105 selector is expr

or variable

C1103 (R1105) variable shall not be a coindexed object.

[root@localhost flang]# cat -n /root/LLVM/selecttype_coarray.f90

 1	class(*),allocatable :: calc[:]
 2	integer :: icoa[*]
 3	
 4	associate(sel=>icoa[2])
 5	end associate
 6	
 7	icoa = 2
 8	allocate(integer::calc[*])
 9	select type(sel=>calc[2])
10	 type is(integer)
11	  sel = 2
12	end select
13	end

Diff Detail

Event Timeline

inderjeet-hcl created this revision.Sep 2 2020, 11:10 PM
inderjeet-hcl requested review of this revision.Sep 2 2020, 11:10 PM
PeteSteinfeld retitled this revision from Fix for PR47339 to [flang]Fix for PR47339.Sep 3 2020, 7:27 AM
klausler added inline comments.
flang/lib/Semantics/resolve-names.cpp
5049

If details.expr() is vacant, so will GetCurrentAssociation().selector.expr be, yes? I think that you can use one or the other. This would be shorter:

if (ExtractCoarrayRef(GetCurrentAssociation().selector.expr)) { // C1103
  Say(...);
}
5054

type is unused

inderjeet-hcl added inline comments.Sep 3 2020, 5:27 PM
flang/lib/Semantics/resolve-names.cpp
5054

It seems usage of type is not required, I will share updated code.

inderjeet-hcl added inline comments.Sep 3 2020, 5:33 PM
flang/lib/Semantics/resolve-names.cpp
5049

I agree, I will update code to pass GetCurrentAssociation().selector.expr directly to function ExtractCoarrayRef.
I used additional checks here as similar code was present in function SetTypeFromAssociation(Symbol &symbol). It seems SetTypeFromAssociation needs additional checks as it is getting called from other locations also.

Modified resolve-names.cpp to incorporate review comments. Also, removed comment related to C1103 from tools.cpp.

klausler accepted this revision.Sep 8 2020, 10:17 AM
This revision is now accepted and ready to land.Sep 8 2020, 10:17 AM

Is something blocking this change being committed?

@DavidTruby changes were committed on 9th Sep. commit ID is 5ec043e.

Ah ok, can we close this review then? Thanks!

@DavidTruby do I need to take any action to close the review ?