User account creation filtered due to spam.

Bug 43412 - [OOP] BT_CLASS does not does not set array spec
Summary: [OOP] BT_CLASS does not does not set array spec
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 major
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
Keywords: accepts-invalid, rejects-valid
Depends on:
Blocks: 18918
  Show dependency treegraph
Reported: 2010-03-17 22:20 UTC by Tobias Burnus
Modified: 2016-11-16 15:29 UTC (History)
4 users (show)

See Also:
Known to work: 4.7.4, 4.8.0, 4.9.0
Known to fail:
Last reconfirmed:

coarray_13.f90 test case (478 bytes, text/plain)
2010-04-28 08:57 UTC, Tobias Burnus

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-03-17 22:20:42 UTC
symbol.c's gfc_build_class_symbol has:

  (*as) = NULL;  /* XXX */

Thus the following invalid program is accepted as the check for
"Assumed size array at %L must be a dummy argument" fails as sym->as == NULL.

module m
  type t
  end type t
end module m
subroutine foo()
use m
  class(t), pointer :: y(*) ! <<< invalid
Comment 1 Tobias Burnus 2010-04-28 08:57:43 UTC
Created attachment 20505 [details]
coarray_13.f90 test case

Depending on this fix are constraint checking for coarrays, cf. attached test case.

  * * *

Current result:
  allocate(t :: z[*])
Error: Unexpected coarray designator at (1)

Reason: gfc_match_array_ref's corank argument is 0. And the argument is sym->as or component->as (cf. primary).

 * * *

  class(t), allocatable :: z[:] ! Fails due to "sym->attr.allocatable
Error: Variable 'z' at (1) is a coarray or has a coarray component and is not ALLOCATABLE, SAVE nor a dummy argument

See check in resolve.c's resolve_symbol. And I do not really want to add tons of special cases for BT_CLASS; the check is already quite long:

  /* F2008, C526.  The function-result case was handled above.  */
  if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp)
       || sym->attr.codimension)
      && !(sym->attr.allocatable || sym->attr.dummy || sym->
           || sym->ns->proc_name->attr.flavor == FL_MODULE
           || sym->ns->proc_name->attr.is_main_program
           || sym->attr.function || sym->attr.result || sym->attr.use_assoc))

 * * *

Possibly related: PR 41539 (also "as = NULL").
Comment 2 Dominique d'Humieres 2012-01-28 23:47:42 UTC
With trunk at revision 183668, compiling the test in comment #0 gives the error

[macbook] f90/bug% gfc pr43412.f90 

  class(t), pointer :: y(*) ! <<< invalid
Error: Assumed size polymorphic objects or components, such as that at (1), have not yet been implemented

while the test in comment #1 compiles without error. AFAIU this is the expected behavior, isn't it?
Comment 3 Mikael Morin 2013-06-11 15:25:22 UTC
(In reply to Dominique d'Humieres from comment #2)
> while the test in comment #1 compiles without error. AFAIU this is the
> expected behavior, isn't it?
It seems so.