[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2024-03-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #12 from GCC Commits  ---
The releases/gcc-13 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:90442fb421823153c4f762a2d26a0d700af2e6c3

commit r13-8443-g90442fb421823153c4f762a2d26a0d700af2e6c3
Author: Harald Anlauf 
Date:   Fri Mar 1 19:21:27 2024 +0100

Fortran: improve checks of NULL without MOLD as actual argument [PR104819]

gcc/fortran/ChangeLog:

PR fortran/104819
* check.cc (gfc_check_null): Handle nested NULL()s.
(is_c_interoperable): Check for MOLD argument of NULL() as part of
the interoperability check.
* interface.cc (gfc_compare_actual_formal): Extend checks for
NULL()
actual arguments for presence of MOLD argument when required by
Interp J3/22-146.

gcc/testsuite/ChangeLog:

PR fortran/104819
* gfortran.dg/assumed_rank_9.f90: Adjust testcase use of NULL().
* gfortran.dg/pr101329.f90: Adjust testcase to conform to interp.
* gfortran.dg/null_actual_4.f90: New test.

(cherry picked from commit db0b6746be075e43c8142585968483e125bb52d0)

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2024-03-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #11 from GCC Commits  ---
The releases/gcc-13 branch has been updated by Harald Anlauf
:

https://gcc.gnu.org/g:ba4b4b3864d426835ea10e900a4e1dd466d06e51

commit r13-8442-gba4b4b3864d426835ea10e900a4e1dd466d06e51
Author: Harald Anlauf 
Date:   Wed Nov 22 21:45:46 2023 +0100

testsuite: fortran: fix invalid testcases (missing MOLD argument to NULL)

The Fortran standard requires that NULL() passed to an assumed-rank
dummy argument has a MOLD argument.

gcc/testsuite/ChangeLog:

PR fortran/104819
* gfortran.dg/assumed_rank_10.f90: Add MOLD argument to NULL().
* gfortran.dg/assumed_rank_8.f90: Likewise.

(cherry picked from commit 7646b5d88056cf269ff555afe95bc361dcf5e5c0)

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2024-03-01 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #10 from GCC Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:db0b6746be075e43c8142585968483e125bb52d0

commit r14-9261-gdb0b6746be075e43c8142585968483e125bb52d0
Author: Harald Anlauf 
Date:   Fri Mar 1 19:21:27 2024 +0100

Fortran: improve checks of NULL without MOLD as actual argument [PR104819]

gcc/fortran/ChangeLog:

PR fortran/104819
* check.cc (gfc_check_null): Handle nested NULL()s.
(is_c_interoperable): Check for MOLD argument of NULL() as part of
the interoperability check.
* interface.cc (gfc_compare_actual_formal): Extend checks for
NULL()
actual arguments for presence of MOLD argument when required by
Interp J3/22-146.

gcc/testsuite/ChangeLog:

PR fortran/104819
* gfortran.dg/assumed_rank_9.f90: Adjust testcase use of NULL().
* gfortran.dg/pr101329.f90: Adjust testcase to conform to interp.
* gfortran.dg/null_actual_4.f90: New test.

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2024-02-29 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |anlauf at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #9 from anlauf at gcc dot gnu.org ---
First patch:

https://gcc.gnu.org/pipermail/fortran/2024-February/060289.html

(slightly corrected version from comment#3).

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #8 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

https://gcc.gnu.org/g:7646b5d88056cf269ff555afe95bc361dcf5e5c0

commit r14-5798-g7646b5d88056cf269ff555afe95bc361dcf5e5c0
Author: Harald Anlauf 
Date:   Wed Nov 22 21:45:46 2023 +0100

testsuite: fortran: fix invalid testcases (missing MOLD argument to NULL)

The Fortran standard requires that NULL() passed to an assumed-rank
dummy argument has a MOLD argument.

gcc/testsuite/ChangeLog:

PR fortran/104819
* gfortran.dg/assumed_rank_10.f90: Add MOLD argument to NULL().
* gfortran.dg/assumed_rank_8.f90: Likewise.

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-16 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #56546|0   |1
is obsolete||

--- Comment #7 from anlauf at gcc dot gnu.org ---
Created attachment 56607
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56607=edit
Updated patch

This patch adds further checking to handle F2008/F2018 differences.
It is now more in line with NAG (and sort-of Intel) here.
However, regression testing produces further fallout:

gfortran.dg/pointer_intent_7.f90 - harmless, needs adjusted pattern,

but the following appear to be really invalid according to NAG and visual
inspection:

gfortran.dg/class_dummy_4.f03
gfortran.dg/class_optional_2.f90
gfortran.dg/finalize_12.f90
gfortran.dg/select_type_30.f03

This is now getting really messy...

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-14 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #6 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #5)
> We need to detect and diagnose violations of the above.

Example:

program main
  implicit none
  type t
integer :: i
  end type t

  type(t),  allocatable, target :: xa
  type(t),  pointer :: xp
  class(t), allocatable, target :: ya
  class(t), pointer :: yp

  call foo_p (xp) ! Invalid
  call foo_p (xa) ! Invalid in F2008, valid in F2018

  call foo_p (yp) ! Valid, OK
  call foo_p (ya) ! Valid, OK

contains

  subroutine foo_p (x)
class(t), pointer, intent(in) :: x
  end subroutine

end

The lines marked invalid are detected for -std=f2003, but not for >= f2008.

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-12 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #5 from anlauf at gcc dot gnu.org ---
Created attachment 56563
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56563=edit
Partial testsuite fixes

This patch contains obvious fixes to 3 testcases, except for
assumed_rank_9.f90,
which is more severe, as it violates

! F2018:15.5.2.5  Allocatable and pointer dummy variables
!
! The actual argument shall be polymorphic if and only if the associated
! dummy argument is polymorphic, and either both the actual and dummy
! arguments shall be unlimited polymorphic, or the declared type of the
! actual argument shall be the same as the declared type of the dummy
! argument.
!
! F2023:15.5.2.6  has the same text

which is detected (mostly) by NAG and Intel.

We need to detect and diagnose violations of the above.

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-09 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #56519|0   |1
is obsolete||

--- Comment #4 from anlauf at gcc dot gnu.org ---
Created attachment 56546
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56546=edit
Second version of a patch

This patch contains a revised checking of NULL() as actual argument
which should be consistent with F2008+ for allocatables.

It also fixes the cases where NULL(x) is passed to an assumed-rank
dummy, but only for scalar x so far.

I might need some assistance in how to produce a proper descriptor to pass
for rank > 0.  (I added a gfc_internal_error (TODO) for the allocatable case.)

Regtests essentially fine, but requires fixing these invalid testcases:

! gfortran.dg/assumed_rank_8.f90
! gfortran.dg/assumed_rank_9.f90
! gfortran.dg/assumed_rank_10.f90
! gfortran.dg/pr101329.f90

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #3 from anlauf at gcc dot gnu.org ---
Created attachment 56519
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56519=edit
Partial patch

This patch adjusts the checking so that nested NULL()s are accepted,
tries to implement Interp J3/22-146 when passing NULL() to an
assumed-rank dummy, and catches NULL() passed to an assumed-length dummy.

TODO: fix handling of NULL(mold) in gfc_conv_procedure_call.

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2023-11-06 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Last reconfirmed||2023-11-06
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
 CC||anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
There are also a few cases where null(null()) is erroneously rejected:

program p
  implicit none
  integer, pointer :: x
  call foo (null (x))! valid and accepted
  call foo (null ()) ! valid and accepted
  call foo (null (null (x))) ! valid but rejected
  call foo (null (null ()))  ! valid but rejected
contains
  subroutine foo (y)
integer, pointer :: y
  end subroutine foo
end

[Bug fortran/104819] Reject NULL without MOLD as actual to an assumed-rank dummy

2022-03-07 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104819

--- Comment #1 from Tobias Burnus  ---
(In reply to Tobias Burnus from comment #0)
> I believe this should be rejected as the rank is not known without a MOLD.

That's now an interpretation request:
https://j3-fortran.org/doc/year/22/22-146.txt

(Note: might see updates, such as 22-146r1.txt or ...)

 * * *

In the email thread, also an issue related to C_SIZEOF was mentioned:
https://j3-fortran.org/doc/year/22/22-101r1.txt

Example from the IR, see IR for details about the validity.

program p
 use iso_c_binding
 implicit none
 integer(c_int), pointer :: int_s
 integer(c_int), pointer :: int_a(:)
 print *, c_sizeof (c_null_ptr) ! (A)
 print *, c_sizeof (null ())! (B)
 print *, c_sizeof (null (int_s)) ! (C)
 print *, c_sizeof (null (int_a)) ! (D)
end