Bug 84119 - Type parameter inquiry for PDT returns array instead of scalar
Summary: Type parameter inquiry for PDT returns array instead of scalar
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks: PDT 84094
  Show dependency treegraph
 
Reported: 2018-01-30 06:35 UTC by Neil Carlson
Modified: 2021-05-04 12:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-01-31 00:00:00


Attachments
Fix for the PR (1.33 KB, patch)
2021-04-20 11:25 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Carlson 2018-01-30 06:35:28 UTC
There seems to be a misconception in the implementation of PDT that the type parameters are (in part) just regular components of the type, so that for

type foo(a)
  integer, len :: a
end type
type(foo(a)) :: array(9)

the type inquiry array%a should give a rank-1 array of size 9. This is incorrect. Type parameters are not components of the type. The F08 standard clearly distinguishes between type parameter definition statements and component definition statements. See R425, R431, R435, and in particular see Note 6.7 which says "It [array%a, for example] is scalar even if designator is an array."

Here's a test case that should pass.  GFortran will bail on both stop lines.

type :: vector(dim,kind)
  integer, len :: dim
  integer, kind :: kind
end type
type(vector(3,1)) :: a(10)
if (size(shape(a%dim)) /= 0) stop 1
if (size(shape(a%kind)) /= 0) stop 2
end
Comment 1 Dominique d'Humieres 2018-01-31 14:33:16 UTC
Confirmed.
Comment 2 Paul Thomas 2021-04-20 11:25:51 UTC
Created attachment 50636 [details]
Fix for the PR

Sorry for the wait. Your analysis is completely correct. Thanks for pointing it out.

The attached will be submitted to the fortran list in a few minutes. It regression tests OK.

Paul