public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure
@ 2021-02-10 18:17 pault at gcc dot gnu.org
2021-02-13 11:58 ` [Bug fortran/99065] " dominiq at lps dot ens.fr
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2021-02-10 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99065
Bug ID: 99065
Summary: ASSOCIATE function selector expression "no IMPLICIT
type" failure
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: pault at gcc dot gnu.org
Target Milestone: ---
Created attachment 50164
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50164&action=edit
Testcase illustrating the failure
This bug was detected in testing variations of the testcase in PR98897.
The attached fails with:
../pr98897/foo1.f90:9:20:
9 | print *, var%i
| 1
Error: Symbol ‘var’ at (1) has no IMPLICIT type
If the contained procedures 'foo' and 'bar' are interchanged it compiles and
produces the intended result.
All component references suffer from this problem. Intrinsic types are fixed up
by parse.c(gfc_fixup_sibling_symbols) but there is no simple way to do this for
derived type or class selectors.
Certain operator expressions also suffer from this problem.
It is caused by parsing and matching in gfortran being single pass. This means
that unless the specification of 'bar', in this case, has been obtained, the
type of 'var' cannot be determined and primary.c(gfc_match_varspec) is bound to
return MATCH_NO.
I am looking at either two passes for contained procedures (specification
blocks first, followed by code blocks) or a fixup in gfc_match_varspec that
looks through the derived types for successful matches.
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/99065] ASSOCIATE function selector expression "no IMPLICIT type" failure
2021-02-10 18:17 [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure pault at gcc dot gnu.org
@ 2021-02-13 11:58 ` dominiq at lps dot ens.fr
2023-06-28 16:39 ` pault at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-02-13 11:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99065
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-02-13
Status|UNCONFIRMED |NEW
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed since at least GCC7.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/99065] ASSOCIATE function selector expression "no IMPLICIT type" failure
2021-02-10 18:17 [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure pault at gcc dot gnu.org
2021-02-13 11:58 ` [Bug fortran/99065] " dominiq at lps dot ens.fr
@ 2023-06-28 16:39 ` pault at gcc dot gnu.org
2024-03-15 6:53 ` cvs-commit at gcc dot gnu.org
2024-03-15 7:08 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2023-06-28 16:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99065
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
I actually worked on this one first but have to give the prior credit to Ian
Harvey.
Paul
*** This bug has been marked as a duplicate of bug 89645 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/99065] ASSOCIATE function selector expression "no IMPLICIT type" failure
2021-02-10 18:17 [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure pault at gcc dot gnu.org
2021-02-13 11:58 ` [Bug fortran/99065] " dominiq at lps dot ens.fr
2023-06-28 16:39 ` pault at gcc dot gnu.org
@ 2024-03-15 6:53 ` cvs-commit at gcc dot gnu.org
2024-03-15 7:08 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-15 6:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99065
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/99065] ASSOCIATE function selector expression "no IMPLICIT type" failure
2021-02-10 18:17 [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure pault at gcc dot gnu.org
` (2 preceding siblings ...)
2024-03-15 6:53 ` cvs-commit at gcc dot gnu.org
@ 2024-03-15 7:08 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2024-03-15 7:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99065
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
This mega-patch, on the scale of the importance of the problem, was required
because of gfortran's one pass parsing. It might be a temporary fix because I
am contemplating how an initial pass of contained procedures might be
introduced.
Fixed on mainline.
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-15 7:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 18:17 [Bug fortran/99065] New: ASSOCIATE function selector expression "no IMPLICIT type" failure pault at gcc dot gnu.org
2021-02-13 11:58 ` [Bug fortran/99065] " dominiq at lps dot ens.fr
2023-06-28 16:39 ` pault at gcc dot gnu.org
2024-03-15 6:53 ` cvs-commit at gcc dot gnu.org
2024-03-15 7:08 ` pault 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).