[PATCH] Fortran: Fixes and additional tests for shape/ubound/size [PR94070]

Sandra Loosemore sandra@codesourcery.com
Wed Oct 20 20:03:35 GMT 2021


This patch started out as some additional testcases for the SHAPE, 
UBOUND, and SIZE intrinsic extensions for assumed-rank arrays added by 
TS29113; I realized a while ago that I had not added test coverage for 
polymorphic arguments.  My guess that this was a likely trouble spot was 
correct as the new test cases did not work.  :-(

The one that was most concerning was an ICE when calling the SHAPE 
intrinsic with an assumed-rank class type argument, as reported in 
PR94070.  (I think this ICE is similar to the one reported in PR102641 
that Tobias thinks is a problem with the scalarizer.)  In this case, 
SHAPE was calling a library function and trying to copy the array 
contents to a temporary, which is really stupid because SHAPE only needs 
to look at the descriptor and not the array contents.  I thought we 
could handle this inline the same as UBOUND and LBOUND, by extending 
gfc_trans_intrinsic_bound, and avoid the library function entirely.

Then, I found some other existing problems in gfc_trans_intrinsic_bound; 
the conditional it was building to test for the extent-zero special 
cases for LBOUND and UBOUND was completely wrong, and the compile-time 
test for the assumed-rank/assumed-size case was wrong too.  So I ended 
up rewriting large parts of that function.

I also fixed a bug in the SIZE intrinsic where it was not taking the 
class types into account.  (SIZE is already being handled inline in a 
separate place, otherwise I might've merged it into 
gfc_trans_intrinsic_bound as well.)

While I was at it I also added 3 more testcases for these functions to 
test for correct behavior with bind(c).  All 6 new tests PASS now, and 
there are no other regressions.

OK to commit?

-Sandra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr94070.patch
Type: text/x-patch
Size: 37723 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211020/e8c8e53a/attachment-0001.bin>


More information about the Gcc-patches mailing list