public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic
@ 2021-03-18 17:49 aserranot at aemet dot es
  2021-03-18 20:16 ` [Bug fortran/99651] " burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: aserranot at aemet dot es @ 2021-03-18 17:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99651
           Summary: Cannot change attributes of USE-associated intrinsic
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aserranot at aemet dot es
  Target Milestone: ---

Created attachment 50424
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50424&action=edit
Source files to reproduce the problem

When I make a minimal example, the problem does not appear. So, I have taken my
code and begun to simplify it while testing that, after each simplification,
the problem remains.

I use a fortran wrapper for the udunits by Michel Valin (Copyright Université
du Québec à Montréal) and it seems that when I erase the corresponding use
statement and all the variables of a type defined in the udunits2 wrapper, the
problem disapears. So I think that the problem is triggered in some way by that
module.

I attach my code and the module.

To compile, issue the following commands in a directory where you have the
files f_udunits_2.f90, f_udunits_2.inc and gfortran_bug_example.f90:

gfortran -J. -cpp -fno-realloc-lhs -fopenmp -fcheck=bounds -fcheck=all -g -O0 
-Wall   -c f_udunits_2.f90

gfortran -J. -cpp -fno-realloc-lhs -fopenmp -fcheck=bounds -fcheck=all -g -O0 
-Wall   -c gfortran_bug_example.f90 

In my system, the output from the last command is:
gfortran_bug_example.f90:41:53:

   41 |     type(typeNode),   pointer       :: Next => null()
      |                                                     1
Error: No se pueden cambiar los atributos del símbolo asociado con USE null en
(1)
gfortran_bug_example.f90:45:45:

   45 |     type(typeNode), pointer :: Head => null()
      |                                             1
Error: No se pueden cambiar los atributos del símbolo asociado con USE null en
(1)
gfortran_bug_example.f90:46:45:

   46 |     type(typeNode), pointer :: Last => null()
      |                                             1
Error: No se pueden cambiar los atributos del símbolo asociado con USE null en
(1)
gfortran_bug_example.f90:62:30:

   62 |         class(typeFieldsList)   :: FieldsList
      |                              1
Error: Derived type ‘typefieldslist’ at (1) is being used before it is defined
gfortran_bug_example.f90:66:30:

   66 |         class(typeFieldsList)               :: Fields
      |                              1
Error: Derived type ‘typefieldslist’ at (1) is being used before it is defined
gfortran_bug_example.f90:67:25:

   67 |         class(typeField),       intent(in)  :: Field
      |                         1
Error: Derived type ‘typefield’ at (1) is being used before it is defined
gfortran_bug_example.f90:71:30:

   71 |         class(typeFieldsList),  target              :: Fields
      |                              1
Error: Derived type ‘typefieldslist’ at (1) is being used before it is defined
gfortran_bug_example.f90:73:25:

   73 |         class(typeField), pointer     :: Ptr
      |                         1
Error: Derived type ‘typefield’ at (1) is being used before it is defined

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
@ 2021-03-18 20:16 ` burnus at gcc dot gnu.org
  2021-03-18 20:16 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-03-18 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Reduced example:

module m
    type :: CHAR_STAR
      character(len=1),dimension(:),pointer :: ptr
    end type
    type(CHAR_STAR), parameter ::CHAR_STAR_NULL = CHAR_STAR(NULL())
end module m

use m
type typeNode
    type(typeNode),   pointer       :: Next => null()
end type typeNode
end

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
  2021-03-18 20:16 ` [Bug fortran/99651] " burnus at gcc dot gnu.org
@ 2021-03-18 20:16 ` burnus at gcc dot gnu.org
  2021-03-18 20:25 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-03-18 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-03-18
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
That's for matching 'NULL()' in:
  CHAR_STAR_NULL = CHAR_STAR(NULL())
The problem is that during matching we end up
in  gfc_match_rvalue  for:
      /* Give up, assume we have a function.  */
      e->expr_type = EXPR_FUNCTION;

      if (!sym->attr.function
          && !gfc_add_function (&sym->attr, sym->name, NULL))
which then also set:
  if (attr->flavor != FL_PROCEDURE
      && !gfc_add_flavor (attr, FL_PROCEDURE, name, where))
    return false;
 attr->function = 1


And later then:
  resolve_function → resolve_unknown_f → gfc_intrinsic_func_interface
the latter than has:
  if (sym->attr.flavor == FL_UNKNOWN)
    {
      sym->attr.function = 1;
      sym->attr.intrinsic = 1;
      sym->attr.flavor = FL_PROCEDURE;
    }

Thus, at the end intrinsic is not set in the module.
For the next use, we run into the following in gfc_match_null:

  if (sym->attr.proc != PROC_INTRINSIC
      && !(sym->attr.use_assoc && sym->attr.intrinsic)
      && (!gfc_add_procedure(&sym->attr, PROC_INTRINSIC, sym->name, NULL)
          || !gfc_add_function (&sym->attr, sym->name, NULL)))
    return MATCH_ERROR;

Here, we have:
- PROC_UNKNOWN
- sym->attr.intrinsic == 0
- gfc_add_procedure
  → this calls 'check_used' → which fails due to attr->use_assoc != 0.

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
  2021-03-18 20:16 ` [Bug fortran/99651] " burnus at gcc dot gnu.org
  2021-03-18 20:16 ` burnus at gcc dot gnu.org
@ 2021-03-18 20:25 ` burnus at gcc dot gnu.org
  2021-03-19  8:51 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-03-18 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The obvious idea to do:

  if (sym->attr.flavor == FL_UNKNOWN || sym->attr.flavor == FL_PROCEDURE)

in gfc_intrinsic_func_interface works, but has the side effect that for

  print *, allocated(f)

('f' is a function) of gfortran.dg/allocatable_scalar_11.f90
the error is generated by   resolve_generic_f's

  m = gfc_intrinsic_func_interface (expr, 0);
...
  if (m == MATCH_NO)
    gfc_error ("Generic function %qs at %L is not consistent with a "
               "specific intrinsic interface", expr->symtree->n.sym->name,

Without that 'obvious' patch, the error is generated by the call to
  check_specific (specific, expr, 0)
also within gfc_intrinsic_func_interface.

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
                   ` (2 preceding siblings ...)
  2021-03-18 20:25 ` burnus at gcc dot gnu.org
@ 2021-03-19  8:51 ` burnus at gcc dot gnu.org
  2021-03-26  7:40 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-03-19  8:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566956.html

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
                   ` (3 preceding siblings ...)
  2021-03-19  8:51 ` burnus at gcc dot gnu.org
@ 2021-03-26  7:40 ` cvs-commit at gcc dot gnu.org
  2021-03-29  9:47 ` cvs-commit at gcc dot gnu.org
  2021-05-03 13:20 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-26  7:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:9d45e848d02e71c11420ec49630281e9a29c89b8

commit r11-7843-g9d45e848d02e71c11420ec49630281e9a29c89b8
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Mar 26 08:39:24 2021 +0100

    Fortran: Fix intrinsic null() handling [PR99651]

    gcc/fortran/ChangeLog:

            PR fortran/99651
            * intrinsic.c (gfc_intrinsic_func_interface): Set
            attr.proc = PROC_INTRINSIC if FL_PROCEDURE.

    gcc/testsuite/ChangeLog:

            PR fortran/99651
            * gfortran.dg/null_11.f90: New test.

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
                   ` (4 preceding siblings ...)
  2021-03-26  7:40 ` cvs-commit at gcc dot gnu.org
@ 2021-03-29  9:47 ` cvs-commit at gcc dot gnu.org
  2021-05-03 13:20 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-29  9:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Tobias Burnus
<burnus@gcc.gnu.org>:

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

commit r10-9552-gf340327d9b3d9f815b45683b739f2321545157cf
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Fri Mar 26 08:39:24 2021 +0100

    Fortran: Fix intrinsic null() handling [PR99651]

    gcc/fortran/ChangeLog:

            PR fortran/99651
            * intrinsic.c (gfc_intrinsic_func_interface): Set
            attr.proc = PROC_INTRINSIC if FL_PROCEDURE.

    gcc/testsuite/ChangeLog:

            PR fortran/99651
            * gfortran.dg/null_11.f90: New test.

    (cherry picked from commit 9d45e848d02e71c11420ec49630281e9a29c89b8)

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

* [Bug fortran/99651] Cannot change attributes of USE-associated intrinsic
  2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
                   ` (5 preceding siblings ...)
  2021-03-29  9:47 ` cvs-commit at gcc dot gnu.org
@ 2021-05-03 13:20 ` burnus at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-05-03 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Close as FIXED - it is fixed in GCC 10 and in GCC 11 (before the first release,
i.e. it is in 11.1 and in 12).

Thanks for the report!

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

end of thread, other threads:[~2021-05-03 13:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 17:49 [Bug fortran/99651] New: Cannot change attributes of USE-associated intrinsic aserranot at aemet dot es
2021-03-18 20:16 ` [Bug fortran/99651] " burnus at gcc dot gnu.org
2021-03-18 20:16 ` burnus at gcc dot gnu.org
2021-03-18 20:25 ` burnus at gcc dot gnu.org
2021-03-19  8:51 ` burnus at gcc dot gnu.org
2021-03-26  7:40 ` cvs-commit at gcc dot gnu.org
2021-03-29  9:47 ` cvs-commit at gcc dot gnu.org
2021-05-03 13:20 ` burnus 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).