[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-09-04 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

Paul Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #7 from Paul Thomas  ---
Fixed on mainline

Thanks for the report

Paul

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-11 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

--- Comment #6 from GCC Commits  ---
The master branch has been updated by Paul Thomas :

https://gcc.gnu.org/g:2aac5a6fa53277216b30c3d8aa0f6c277f55

commit r16-3135-g2aac5a6fa53277216b30c3d8aa0f6c277f55
Author: Paul Thomas 
Date:   Mon Aug 11 21:34:07 2025 +0100

Fortran: gfortran rejects procedure binding on PDT [PR121398]

2025-08-11  Paul Thomas  

gcc/fortran
PR fortran/121398
* resolve.cc (check_pdt_args): New function.
(check_generic_tbp_ambiguity): Use it to ensure that args to
typebound procedures that do not have the same declared type as
the containing derived type have 'pass1/2' set to null. This
avoids false ambiguity errors.
(resolve_typebound_procedure): Do not generate a wrong type
error for typebound procedures marked as pass if they are of a
different declared type to the containing pdt_type.

gcc/testsuite/
PR fortran/121398
* gfortran.dg/pdt_generic_1.f90: New test.

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-11 Thread damian at archaeologic dot codes via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

--- Comment #5 from Damian Rouson  ---
Awesome!  Thanks, Paul. If Jerry can put a patched version of the compiler on a
git branch for me to pull and build, I'll test this and report what comes up
next.

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-10 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

Paul Thomas  changed:

   What|Removed |Added

  Attachment #62087|0   |1
is obsolete||

--- Comment #4 from Paul Thomas  ---
Created attachment 62097
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62097&action=edit
Fix for this PR

This seems to do the job. The next step is to make sure that invalid interfaces
are still detected and provide testcases.

Roll on the next PDT show stopper :-)

Paul

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-09 Thread damian at archaeologic dot codes via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

--- Comment #3 from Damian Rouson  ---
Hooray!!  Thanks, Paul.

D

On Sat, Aug 9, 2025 at 02:56 pault at gcc dot gnu.org <
[email protected]> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398
>
> --- Comment #2 from Paul Thomas  ---
> Created attachment 62087
>   --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62087&action=edit
> First attempt at a fix - work in progress!
>
> The test below runs correctly with this patch applied. ifx and flang-new
> accept
> it and produce the same result. Nagfor doesn't like the interfaces for some
> reason.
>
> The chunk in decl.cc is a proper fix for the PDT part. The zeroed out
> chunks in
> resolve.cc are necessary to prevent errors and will be subject to
> investigation
> one after another.
>
> Paul
>
> module tensor_m
>   implicit none
>
>   type tensor_t(k)
> integer, kind :: k
>   contains
> procedure default_real_num_components
> procedure double_precision_num_components
> generic :: num_components => default_real_num_components, &
>  double_precision_num_components
>   end type
>
>   interface
>
> module function default_real_num_components(self) result(res)
>   implicit none
>   class(tensor_t(kind(0.))) self
>   integer :: res
> end function
>
> module function double_precision_num_components(self) result(res)
>   implicit none
>   class(tensor_t(kind(0.0_16))) self
>   integer :: res
> end function
>
>   end interface
>
> end module
>
> submodule (tensor_m) tensor_m_components
> contains
> module procedure default_real_num_components
>   implicit none
>   res = 1
> end
>
> module procedure double_precision_num_components
>   implicit none
>   res = 2
> end
> end
>
> use tensor_m
> type (tensor_t(kind(0.))) :: a
> type (tensor_t(kind(0.0_16))) :: b
> print *, a%num_components ()
> print *, b%num_components ()
> end
>
> --
> You are receiving this mail because:
> You reported the bug.

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-09 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

--- Comment #2 from Paul Thomas  ---
Created attachment 62087
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62087&action=edit
First attempt at a fix - work in progress!

The test below runs correctly with this patch applied. ifx and flang-new accept
it and produce the same result. Nagfor doesn't like the interfaces for some
reason.

The chunk in decl.cc is a proper fix for the PDT part. The zeroed out chunks in
resolve.cc are necessary to prevent errors and will be subject to investigation
one after another.

Paul

module tensor_m
  implicit none

  type tensor_t(k)
integer, kind :: k
  contains
procedure default_real_num_components
procedure double_precision_num_components
generic :: num_components => default_real_num_components, &
 double_precision_num_components
  end type

  interface

module function default_real_num_components(self) result(res)
  implicit none
  class(tensor_t(kind(0.))) self
  integer :: res
end function

module function double_precision_num_components(self) result(res)
  implicit none
  class(tensor_t(kind(0.0_16))) self
  integer :: res
end function

  end interface

end module 

submodule (tensor_m) tensor_m_components
contains
module procedure default_real_num_components
  implicit none
  res = 1
end

module procedure double_precision_num_components
  implicit none
  res = 2
end
end

use tensor_m
type (tensor_t(kind(0.))) :: a
type (tensor_t(kind(0.0_16))) :: b
print *, a%num_components ()
print *, b%num_components ()
end

[Bug fortran/121398] gfortran rejects procedure binding on PDT

2025-08-05 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121398

Paul Thomas  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 CC||pault at gcc dot gnu.org
   Last reconfirmed||2025-08-05
   Assignee|unassigned at gcc dot gnu.org  |pault at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Paul Thomas  ---
As soon as the final fiddling with the generic statement is done, I will get
onto this.

Thanks

Paul