Bug 52016 - [OOP] Polymorphism and elemental: missing diagnostic
Summary: [OOP] Polymorphism and elemental: missing diagnostic
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-27 10:11 UTC by Dominique d'Humieres
Modified: 2016-11-16 14:31 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2012-01-27 10:11:40 UTC
This PR is probably a duplicate of pr52013 with a fix before submission (see http://gcc.gnu.org/ml/fortran/2012-01/msg00224.html ;-).

While investigating why the test in pr50981 comment #23 was yielding an ICE even with the patch from http://gcc.gnu.org/ml/fortran/2012-01/msg00223.html , I reduced the origin of the ICE to the following test

    type t
      integer :: a
    end type t
  type(t), allocatable :: var1, var2(:)
  allocate(var1, var2(2))
  call sub_ctae(var2)
 if (any (var2%a /= 9)) call abort()

contains
  elemental subroutine sub_ctae(y)
    class(t), intent(inout), optional :: y(:) ! <-- invalid and gives an ICE
!    class(t), intent(inout), optional :: y ! <-- valid and works
    if (present(y)) y%a = 9
    if (present(y)) i = 7
  end subroutine sub_ctae
end

which gives

pr50981_4_red.f90: In function 'sub_ctae':
pr50981_4_red.f90:13:0: internal compiler error: in gfc_conv_descriptor_data_get, at fortran/trans-array.c:147

for an unpatched r183306 and
 
pr50981_4_red.f90: In function 'MAIN__':
pr50981_4_red.f90:6:0: internal compiler error: in fold_convert_loc, at fold-const.c:2016

for my patched tree.
Comment 1 Tobias Burnus 2012-01-27 10:51:18 UTC
(In reply to comment #0)
> This PR is probably a duplicate of pr52013

No, that's a separate issue: That test case will also fail when this PR is fixed. (Currently, it fails because of this PR *and* due to another reason.)


> with a fix before submission
>  http://gcc.gnu.org/ml/fortran/2012-01/msg00224.html

Indeed, that's the patch for this issue.
Comment 2 Tobias Burnus 2012-01-27 13:03:05 UTC
Author: burnus
Date: Fri Jan 27 13:02:54 2012
New Revision: 183620

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183620
Log:
2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52016
        * resolve.c (resolve_formal_arglist): Fix elemental
        constraint checks for polymorphic dummies.

2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52016
        * gfortran.dg/elemental_args_check_5.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/elemental_args_check_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2012-01-27 13:03:44 UTC
FIXED on the trunk (4.7).

Thanks for the bug report!
Comment 4 Tobias Burnus 2012-01-27 13:59:10 UTC
Author: burnus
Date: Fri Jan 27 13:59:04 2012
New Revision: 183625

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183625
Log:
2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52016
        * resolve.c (resolve_formal_arglist): Fix elemental
        constraint checks for polymorphic dummies also for
        pointers.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c