|Summary:||[F03] [F08] Type parameter inquiry (str%len, a%kind) and Complex parts (z%re, z%im)|
|Product:||gcc||Reporter:||Tobias Burnus <burnus>|
|Component:||fortran||Assignee:||Jerry DeLisle <jvdelisle>|
|Severity:||normal||CC:||damian, dfranke, gcc-bugs, gustav.r.jansen, janus, john.harper, jvdelisle, mexas, quantheory, zbeekman|
|Build:||Known to work:|
|Known to fail:||Last reconfirmed:||2009-05-21 20:53:39|
|Bug Depends on:|
|Bug Blocks:||20585, 39627, 29962|
Description Tobias Burnus 2009-05-19 11:26:48 UTC
Type parameter inquiry: str%len is equivalent to len(str) a%kind is equivalent to kind(a) The real fun part starts with user-defined kinds, e.g. type tp(dim) integer, KIND :: dim real :: dist(dim) end type tp type(tp) :: t(5) print *, t%dist%dim Quote from F2008 but F2003 should be the same: "A type parameter inquiry is used to inquire about a type parameter of a data object. It applies to both intrinsic and derived types. R616 type-param-inquiry is designator % type-param-name C622 (R616) The type-param-name shall be the name of a type parameter of the declared type of the object designated by the designator. A deferred type parameter of a pointer that is not associated or of an unallocated allocatable variable shall not be inquired about."
Comment 1 Tobias Burnus 2009-05-19 11:36:30 UTC
Another related item are complex parts; contrary to the type parameter inquiry above, those are lvalues and can be assigned to. (Again a F2003 feature, quote is however from F2008.) "R615 complex-part-designator is designator % RE or designator % IM C621 (R615) The designator shall be of complex type. If complex-part-designator is designator%RE it designates the real part of designator. If it is designator%IM it designates the imaginary part of designator. The type of a complex-part-designator is real, and its kind and shape are those of the designator. NOTE 6.6 The following are examples of complex part designators: impedance%re !-- Same value as REAL(impedance) fft%im !-- Same value as AIMAG(fft) x%im = 0.0 !-- Sets the imaginary part of X to zero"
Comment 2 Daniel Franke 2009-12-06 16:59:27 UTC
Type parameter inquiries are also mentioned in PR29962, comment #10.
Comment 3 Sean Santos 2013-10-31 16:20:17 UTC
Real/imaginary parts seem to be Fortran 2008 only. Len/kind are still Fortran 2003.
Comment 4 janus 2017-08-27 09:59:12 UTC
*** Bug 81707 has been marked as a duplicate of this bug. ***
Comment 5 Jerry DeLisle 2017-10-01 18:26:19 UTC
I think originally this was an enhancement becasue we were focused on F95 back in 2009, now we are going for 2015 stuff so this one is higher interest. Taking.
Comment 6 Jerry DeLisle 2017-10-02 02:07:31 UTC
This works: type tp(dim) integer, KIND :: dim = 3 real :: dist(dim) end type tp type(tp) :: t(5) print *, t%dist(2) print *, t end