public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102003] New: [PDT] Length of character component not simplified
@ 2021-08-20 19:11 anlauf at gcc dot gnu.org
  2022-06-13 13:11 ` [Bug fortran/102003] " wileamyp at outlook dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-20 19:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

            Bug ID: 102003
           Summary: [PDT] Length of character component not simplified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

We should be able to simplify at compile time the following code:

  type pdt(n)
     integer, len     :: n = 8
     character(len=n) :: c
  end type pdt
  type(pdt(42)) :: p
  integer, parameter :: m = len (p% c)  ! rejected
  print *, len (p% c) == 42             ! works, but not simplified
end

Instead we currently get:

foo.f90:6:27:

    6 |   integer, parameter :: m = len (p% c)  ! rejected
      |                           1
Error: Cannot convert UNKNOWN to INTEGER(4) at (1)

(The code is accepted by Intel.)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
@ 2022-06-13 13:11 ` wileamyp at outlook dot com
  2023-06-30  8:22 ` pault at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: wileamyp at outlook dot com @ 2022-06-13 13:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

Wileam Yonatan Phan <wileamyp at outlook dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |wileamyp at outlook dot com

--- Comment #1 from Wileam Yonatan Phan <wileamyp at outlook dot com> ---
Behavior confirmed with master@ff91735a5b8. The error message seems to change
if this code block is commented out in gcc/fortran/expr.cc

---

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index be94c18c836..e5a3df214d7 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -3201,12 +3201,14 @@ gfc_match_init_expr (gfc_expr **result)
       return m;
     }

+  #if 0
   if (gfc_derived_parameter_expr (expr))
     {
       *result = expr;
       gfc_init_expr_flag = false;
       return m;
     }
+  #endif

   t = gfc_reduce_init_expr (expr);
   if (!t)

---

Anyway, the new error message is

pr102003.f90:6:33:

    6 |   integer, parameter :: m = len (p% c)  ! rejected
      |                                 1
Error: Parameter ‘p’ at (1) has not been declared or is a variable, which does
not reduce to a constant expression

Maybe something doesn't work properly in gfc_reduce_init_expr()?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
  2022-06-13 13:11 ` [Bug fortran/102003] " wileamyp at outlook dot com
@ 2023-06-30  8:22 ` pault at gcc dot gnu.org
  2023-07-10 15:53 ` vehre at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu.org @ 2023-06-30  8:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-06-30
             Blocks|                            |82173
     Ever confirmed|0                           |1
                 CC|                            |pault at gcc dot gnu.org

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Added to PDT meta-bug


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82173
[Bug 82173] [meta-bug] [PDT] Parameterized derived type errors

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
  2022-06-13 13:11 ` [Bug fortran/102003] " wileamyp at outlook dot com
  2023-06-30  8:22 ` pault at gcc dot gnu.org
@ 2023-07-10 15:53 ` vehre at gcc dot gnu.org
  2023-07-12 11:35 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2023-07-10 15:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

Andre Vehreschild <vehre at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |vehre at gcc dot gnu.org
                 CC|                            |vehre at gcc dot gnu.org

--- Comment #3 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Created attachment 55514
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55514&action=edit
First shot.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-07-10 15:53 ` vehre at gcc dot gnu.org
@ 2023-07-12 11:35 ` cvs-commit at gcc dot gnu.org
  2023-07-20 11:56 ` vehre at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-12 11:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andre Vehreschild <vehre@gcc.gnu.org>:

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

commit r14-2461-gf9182da3213aa57c16dd0b52862126de4a259f6a
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date:   Wed Jul 12 12:51:30 2023 +0200

    gfortran: Allow ref'ing PDT's len() in parameter-initializer.

    Fix declaring a parameter initialized using a pdt_len reference
    not simplifying the reference to a constant.

    2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

    gcc/fortran/ChangeLog:

            PR fortran/102003
            * expr.cc (find_inquiry_ref): Replace len of pdt_string by
            constant.
            (simplify_ref_chain): Ensure input to find_inquiry_ref is
            NULL.
            (gfc_match_init_expr): Prevent PDT analysis for function calls.
            (gfc_pdt_find_component_copy_initializer): Get the initializer
            value for given component.
            * gfortran.h (gfc_pdt_find_component_copy_initializer): New
            function.
            * simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
            component ref or constant.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pdt_33.f03: New test.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-07-12 11:35 ` cvs-commit at gcc dot gnu.org
@ 2023-07-20 11:56 ` vehre at gcc dot gnu.org
  2024-04-26  7:07 ` cvs-commit at gcc dot gnu.org
  2024-04-26 16:51 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2023-07-20 11:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

Andre Vehreschild <vehre at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
No complaints so far, closing as fixed.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-07-20 11:56 ` vehre at gcc dot gnu.org
@ 2024-04-26  7:07 ` cvs-commit at gcc dot gnu.org
  2024-04-26 16:51 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-26  7:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

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

commit r13-8651-ge207b67fcde224f2be0c79bf2a24f7fc75b6f481
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date:   Wed Jul 12 12:51:30 2023 +0200

    gfortran: Allow ref'ing PDT's len() in parameter-initializer.

    Fix declaring a parameter initialized using a pdt_len reference
    not simplifying the reference to a constant.

    2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

    gcc/fortran/ChangeLog:

            PR fortran/102003
            * expr.cc (find_inquiry_ref): Replace len of pdt_string by
            constant.
            (simplify_ref_chain): Ensure input to find_inquiry_ref is
            NULL.
            (gfc_match_init_expr): Prevent PDT analysis for function calls.
            (gfc_pdt_find_component_copy_initializer): Get the initializer
            value for given component.
            * gfortran.h (gfc_pdt_find_component_copy_initializer): New
            function.
            * simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
            component ref or constant.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pdt_33.f03: New test.

    (cherry picked from commit f9182da3213aa57c16dd0b52862126de4a259f6a)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/102003] [PDT] Length of character component not simplified
  2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2024-04-26  7:07 ` cvs-commit at gcc dot gnu.org
@ 2024-04-26 16:51 ` cvs-commit at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-04-26 16:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102003

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:8ad460ca8824f7e29e38a63f9cb4a9a3b96d506f

commit r12-10396-g8ad460ca8824f7e29e38a63f9cb4a9a3b96d506f
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date:   Wed Jul 12 12:51:30 2023 +0200

    gfortran: Allow ref'ing PDT's len() in parameter-initializer.

    Fix declaring a parameter initialized using a pdt_len reference
    not simplifying the reference to a constant.

    2023-07-12  Andre Vehreschild  <vehre@gcc.gnu.org>

    gcc/fortran/ChangeLog:

            PR fortran/102003
            * expr.cc (find_inquiry_ref): Replace len of pdt_string by
            constant.
            (simplify_ref_chain): Ensure input to find_inquiry_ref is
            NULL.
            (gfc_match_init_expr): Prevent PDT analysis for function calls.
            (gfc_pdt_find_component_copy_initializer): Get the initializer
            value for given component.
            * gfortran.h (gfc_pdt_find_component_copy_initializer): New
            function.
            * simplify.cc (gfc_simplify_len): Replace len() of PDT with pdt
            component ref or constant.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/pdt_33.f03: New test.

    (cherry picked from commit f9182da3213aa57c16dd0b52862126de4a259f6a)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-04-26 16:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 19:11 [Bug fortran/102003] New: [PDT] Length of character component not simplified anlauf at gcc dot gnu.org
2022-06-13 13:11 ` [Bug fortran/102003] " wileamyp at outlook dot com
2023-06-30  8:22 ` pault at gcc dot gnu.org
2023-07-10 15:53 ` vehre at gcc dot gnu.org
2023-07-12 11:35 ` cvs-commit at gcc dot gnu.org
2023-07-20 11:56 ` vehre at gcc dot gnu.org
2024-04-26  7:07 ` cvs-commit at gcc dot gnu.org
2024-04-26 16:51 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).