Bug 87477 (associate) - [meta-bug] [F03] issues concerning the ASSOCIATE statement
Summary: [meta-bug] [F03] issues concerning the ASSOCIATE statement
Status: NEW
Alias: associate
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 9.0
: P4 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: meta-bug
Depends on: 85510 87448 102973 110033 113363 38936 56386 58618 64678 83154 85686 86372 87127 87430 87449 87460 88247 88379 89645 91941 92779 92960 93338 93339 93701 93813 95068 95107 99065 99326 100948 102106 102109 102111 102112 102190 102532 104430 106048 107821 107900 109451 109948 110224 112834 114280
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-01 10:57 UTC by janus
Modified: 2024-03-15 06:53 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-10-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2018-10-01 10:57:33 UTC

    
Comment 1 Dominique d'Humieres 2018-10-05 10:42:24 UTC
Marking as NEW.
Comment 2 GCC Commits 2023-04-08 08:04:30 UTC
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

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

commit r13-7121-geac493851f07df98213ecf67a5e9ab41a7babcd2
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Sat Apr 8 09:04:13 2023 +0100

    Fortran: Fix some of the bugs in associate [PR87477]
    
    2023-04-08  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            * iresolve.cc (gfc_resolve_adjustl, gfc_resolve_adjustr): if
            string length is deferred use the string typespec for result.
            * resolve.cc (resolve_assoc_var): Handle parentheses around the
            target expression.
            (resolve_block_construct): Remove unnecessary static decls.
            * trans-array.cc (gfc_conv_expr_descriptor): Guard string len
            expression in condition. Improve handling of string length and
            span, especially for substrings of the descriptor.
            (duplicate_allocatable): Make element type more explicit with
            'eltype'.
            * trans-decl.cc (gfc_get_symbol_decl): Emit a fatal error with
            appropriate message instead of ICE if symbol type is unknown.
            (gfc_generate_function_code): Set current locus to proc_sym
            declared_at.
            * trans-expr.cc (gfc_get_expr_charlen): Retain last charlen in
            'previous' and use if end expression in substring reference is
            null.
            (gfc_conv_string_length): Use gfc_conv_expr_descriptor if
            'expr_flat' is an array. Add post block to catch deallocation
            of temporaries.
            (gfc_conv_procedure_call): Assign the parmse string length to
            the expression string length, if it is deferred.
            (gfc_trans_alloc_subarray_assign): If this is a deferred string
            length component, store the string length in the hidden comp.
            Update the typespec length accordingly. Generate a new type
            spec for the call to gfc_duplicate-allocatable in this case.
            * trans-io.cc (gfc_trans_transfer): Scalarize transfer of
            deferred character array components.
    
    gcc/testsuite/
            PR fortran/87477
            * gfortran.dg/associate_47.f90 : Enable substring test.
            * gfortran.dg/associate_51.f90 : Update an error message.
            * gfortran.dg/goacc/array-with-dt-2.f90 : Add span to
            uninitialzed dg-warnings.
    
            PR fortran/85686
            PR fortran/88247
            PR fortran/91941
            PR fortran/92779
            PR fortran/93339
            PR fortran/93813
            PR fortran/100948
            PR fortran/102106
            * gfortran.dg/associate_60.f90 : New test
    
            PR fortran/98408
            * gfortran.dg/pr98408.f90 : New test
    
            PR fortran/105205
            * gfortran.dg/pr105205.f90 : New test
    
            PR fortran/106918
            * gfortran.dg/pr106918.f90 : New test
Comment 3 GCC Commits 2023-06-02 07:41:58 UTC
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:3c2eba4b7a2355ed5099e35332388206c484744d

commit r14-1487-g3c2eba4b7a2355ed5099e35332388206c484744d
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Jun 2 08:41:45 2023 +0100

    Fortran: Fix some problems blocking associate meta-bug [PR87477]
    
    2023-06-02  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            * parse.cc (parse_associate): Replace the existing evaluation
            of the target rank with calls to gfc_resolve_ref and
            gfc_expression_rank. Identify untyped target function results
            with structure constructors by finding the appropriate derived
            type.
            * resolve.cc (resolve_symbol): Allow associate variables to be
            assumed shape.
    
    gcc/testsuite/
            PR fortran/87477
            * gfortran.dg/associate_54.f90 : Cope with extra error.
    
            PR fortran/102109
            * gfortran.dg/pr102109.f90 : New test.
    
            PR fortran/102112
            * gfortran.dg/pr102112.f90 : New test.
    
            PR fortran/102190
            * gfortran.dg/pr102190.f90 : New test.
    
            PR fortran/102532
            * gfortran.dg/pr102532.f90 : New test.
    
            PR fortran/109948
            * gfortran.dg/pr109948.f90 : New test.
    
            PR fortran/99326
            * gfortran.dg/pr99326.f90 : New test.
Comment 4 GCC Commits 2023-06-08 06:11:42 UTC
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

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

commit r14-1629-gd08f2e4f74583e27002368989bba197f8eb7f6d2
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Thu Jun 8 07:11:32 2023 +0100

    Fortran: Fix some more blockers in associate meta-bug [PR87477]
    
    2023-06-08  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            PR fortran/99350
            PR fortran/107821
            PR fortran/109451
            * decl.cc (char_len_param_value): Simplify a copy of the expr
            and replace the original if there is no error.
            * gfortran.h : Remove the redundant field 'rankguessed' from
            'gfc_association_list'.
            * resolve.cc (resolve_assoc_var): Remove refs to 'rankguessed'.
            (resolve_variable): Associate names with constant or structure
            constructor targets cannot have array refs.
            * trans-array.cc (gfc_conv_expr_descriptor): Guard expression
            character length backend decl before using it. Suppress the
            assignment if lhs equals rhs.
            * trans-io.cc (gfc_trans_transfer): Scalarize transfer of
            associate variables pointing to a variable. Add comment.
            * trans-stmt.cc (trans_associate_var): Remove requirement that
            the character length be deferred before assigning the value
            returned by gfc_conv_expr_descriptor. Also, guard the backend
            decl before testing with VAR_P.
    
    gcc/testsuite/
            PR fortran/99350
            * gfortran.dg/pr99350.f90 : New test.
    
            PR fortran/107821
            * gfortran.dg/associate_5.f03 : Changed error message.
            * gfortran.dg/pr107821.f90 : New test.
    
            PR fortran/109451
            * gfortran.dg/associate_61.f90 : New test
Comment 5 GCC Commits 2023-06-21 16:06:10 UTC
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:577223aebc7acdd31e62b33c1682fe54a622ae27

commit r14-2022-g577223aebc7acdd31e62b33c1682fe54a622ae27
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Wed Jun 21 17:05:58 2023 +0100

    Fortran: Fix some bugs in associate [PR87477]
    
    2023-06-21  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            PR fortran/88688
            PR fortran/94380
            PR fortran/107900
            PR fortran/110224
            * decl.cc (char_len_param_value): Fix memory leak.
            (resolve_block_construct): Remove unnecessary static decls.
            * expr.cc (gfc_is_ptr_fcn): New function.
            (gfc_check_vardef_context): Use it to permit pointer function
            result selectors to be used for associate names in variable
            definition context.
            * gfortran.h: Prototype for gfc_is_ptr_fcn.
            * match.cc (build_associate_name): New function.
            (gfc_match_select_type): Use the new function to replace inline
            version and to build a new associate name for the case where
            the supplied associate name is already used for that purpose.
            * resolve.cc (resolve_assoc_var): Call gfc_is_ptr_fcn to allow
            associate names with pointer function targets to be used in
            variable definition context.
            * trans-decl.cc (gfc_get_symbol_decl): Unlimited polymorphic
            variables need deferred initialisation of the vptr.
            (gfc_trans_deferred_vars): Do the vptr initialisation.
            * trans-stmt.cc (trans_associate_var): Ensure that a pointer
            associate name points to the target of the selector and not
            the selector itself.
    
    gcc/testsuite/
            PR fortran/87477
            PR fortran/107900
            * gfortran.dg/pr107900.f90 : New test
    
            PR fortran/110224
            * gfortran.dg/pr110224.f90 : New test
    
            PR fortran/88688
            * gfortran.dg/pr88688.f90 : New test
    
            PR fortran/94380
            * gfortran.dg/pr94380.f90 : New test
    
            PR fortran/95398
            * gfortran.dg/pr95398.f90 : Set -std=f2008, bump the line
            numbers in the error tests by two and change the text in two.
Comment 6 GCC Commits 2023-08-27 08:51:49 UTC
The releases/gcc-13 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

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

commit r13-7761-gd6997a5aab7aaa325946a6283bfee8ac2bd9f540
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Sun Aug 27 09:51:32 2023 +0100

    Fortran: Fix some problems blocking associate meta-bug [PR87477]
    
    2023-08-27  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            * parse.cc (parse_associate): Replace the existing evaluation
            of the target rank with calls to gfc_resolve_ref and
            gfc_expression_rank. Identify untyped target function results
            with structure constructors by finding the appropriate derived
            type.
            * resolve.cc (resolve_symbol): Allow associate variables to be
            assumed shape.
    
    gcc/testsuite/
            PR fortran/87477
            * gfortran.dg/associate_54.f90 : Cope with extra error.
    
            PR fortran/102109
            * gfortran.dg/pr102109.f90 : New test.
    
            PR fortran/102112
            * gfortran.dg/pr102112.f90 : New test.
    
            PR fortran/102190
            * gfortran.dg/pr102190.f90 : New test.
    
            PR fortran/102532
            * gfortran.dg/pr102532.f90 : New test.
    
            PR fortran/109948
            * gfortran.dg/pr109948.f90 : New test.
    
            PR fortran/99326
            * gfortran.dg/pr99326.f90 : New test.
Comment 7 GCC Commits 2024-03-15 06:53:17 UTC
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:3fd46d859cda1074125449a4cc680ce59fcebc38

commit r14-9489-g3fd46d859cda1074125449a4cc680ce59fcebc38
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Mar 15 06:52:59 2024 +0000

    Fortran: Fix class/derived/complex function associate selectors [PR87477]
    
    2024-03-15  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/87477
            PR fortran/89645
            PR fortran/99065
            PR fortran/114141
            PR fortran/114280
            * class.cc (gfc_change_class): New function needed for
            associate names, when rank changes or a derived type is
            produced by resolution
            * dump-parse-tree.cc (show_code_node): Make output for SELECT
            TYPE more comprehensible.
            * expr.cc (find_inquiry_ref): Do not simplify expressions of
            an inferred type.
            * gfortran.h : Add 'gfc_association_list' to structure
            'gfc_association_list'. Add prototypes for
            'gfc_find_derived_types', 'gfc_fixup_inferred_type_refs' and
            'gfc_change_class'. Add macro IS_INFERRED_TYPE.
            * match.cc (copy_ts_from_selector_to_associate): Add bolean arg
            'select_type' with default false. If this is a select type name
            and the selector is a inferred type, build the class type and
            apply it to the associate name.
            (build_associate_name): Pass true to 'select_type' in call to
            previous.
            * parse.cc (parse_associate): If the selector is inferred type
            the associate name is too. Make sure that function selector
            class and rank, if known, are passed to the associate name. If
            a function result exists, pass its typespec to the associate
            name.
            * primary.cc (resolvable_fcns): New function to check that all
            the function references are resolvable.
            (gfc_match_varspec): If a scalar derived type select type
            temporary has an array reference, match the array reference,
            treating this in the same way as an equivalence member. Do not
            set 'inquiry' if applied to an unknown type the inquiry name
            is ambiguous with the component of an accessible derived type.
            Check that resolution of the target expression is OK by testing
            if the symbol is declared or is an operator expression, then
            using 'resolvable_fcns' recursively. If all is well, resolve
            the expression. If this is an inferred type with a component
            reference, call 'gfc_find_derived_types' to find a suitable
            derived type. If there is an inquiry ref and the symbol either
            is of unknown type or is inferred to be a derived type, set the
            primary and symbol TKR appropriately.
            * resolve.cc (resolve_variable): Call new function below.
            (gfc_fixup_inferred_type_refs): New function to ensure that the
            expression references for a inferred type are consistent with
            the now fixed up selector.
            (resolve_assoc_var): Ensure that derived type or class function
            selectors transmit the correct arrayspec to the associate name.
            (resolve_select_type): If the selector is an associate name of
            inferred type and has no component references, the associate
            name should have its typespec. Simplify the conversion of a
            class array to class scalar by calling 'gfc_change_class'.
            Make sure that a class, inferred type selector with an array
            ref transfers the typespec from the symbol to the expression.
            * symbol.cc (gfc_set_default_type): If an associate name with
            unknown type has a selector expression, try resolving the expr.
            (find_derived_types, gfc_find_derived_types): New functions
            that search for a derived type with a given name.
            * trans-expr.cc (gfc_conv_variable): Some inferred type exprs
            escape resolution so call 'gfc_fixup_inferred_type_refs'.
            * trans-stmt.cc (trans_associate_var): Tidy up expression for
            'class_target'. Finalize and free class function results.
            Correctly handle selectors that are class functions and class
            array references, passed as derived types.
    
    gcc/testsuite/
            PR fortran/87477
            PR fortran/89645
            PR fortran/99065
            * gfortran.dg/associate_64.f90 : New test
            * gfortran.dg/associate_66.f90 : New test
            * gfortran.dg/associate_67.f90 : New test
    
            PR fortran/114141
            * gfortran.dg/associate_65.f90 : New test
    
            PR fortran/114280
            * gfortran.dg/associate_68.f90 : New test