public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected
@ 2022-05-10 6:02 mscfd at gmx dot net
2022-05-10 18:28 ` [Bug fortran/105543] " anlauf at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mscfd at gmx dot net @ 2022-05-10 6:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
Bug ID: 105543
Summary: Function returning a class array with contiguous
attribute rejected
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mscfd at gmx dot net
Target Milestone: ---
Created attachment 52947
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52947&action=edit
func_contiguous.f90
The attached code, compiled with "gfortran func_contiguous.f90 -c", fails with
the error message
func_contiguous.f90:8:0:
8 | function create() result(x)
|
Error: ‘create’ at (1) has the CONTIGUOUS attribute but is not an array pointer
or an assumed-shape or assumed-rank array.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/105543] Function returning a class array with contiguous attribute rejected
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
@ 2022-05-10 18:28 ` anlauf at gcc dot gnu.org
2023-12-05 20:34 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-05-10 18:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-05-10
Ever confirmed|0 |1
--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.
The code is accepted if you *don't* use the result clause, as in:
function create()
class(a), dimension(:), contiguous, pointer :: create
end function create
There are a couple PRs about declarations involving CLASS where attributes
are specified separately. There could be a relation.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/105543] Function returning a class array with contiguous attribute rejected
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
2022-05-10 18:28 ` [Bug fortran/105543] " anlauf at gcc dot gnu.org
@ 2023-12-05 20:34 ` anlauf at gcc dot gnu.org
2023-12-06 20:33 ` anlauf at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-05 20:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
CC| |anlauf at gcc dot gnu.org
--- Comment #2 from anlauf at gcc dot gnu.org ---
The following hack makes the code compile:
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 166b702cd9a..16813853b30 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -16102,6 +16116,10 @@ resolve_symbol (gfc_symbol *sym)
specification_expr = saved_specification_expr;
}
+ // Hackish fix-up for a CLASS result variable
+ if (sym->ts.type == BT_CLASS && sym->result && sym->result->attr.class_ok)
+ sym->attr.class_ok = sym->result->attr.class_ok;
+
if (sym->ts.type == BT_CLASS && sym->attr.class_ok && sym->ts.u.derived
&& CLASS_DATA (sym))
{
Not sure yet where this should have been properly set in the first place...
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/105543] Function returning a class array with contiguous attribute rejected
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
2022-05-10 18:28 ` [Bug fortran/105543] " anlauf at gcc dot gnu.org
2023-12-05 20:34 ` anlauf at gcc dot gnu.org
@ 2023-12-06 20:33 ` anlauf at gcc dot gnu.org
2023-12-10 19:34 ` cvs-commit at gcc dot gnu.org
2023-12-10 21:40 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-06 20:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |anlauf at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-December/059999.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/105543] Function returning a class array with contiguous attribute rejected
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
` (2 preceding siblings ...)
2023-12-06 20:33 ` anlauf at gcc dot gnu.org
@ 2023-12-10 19:34 ` cvs-commit at gcc dot gnu.org
2023-12-10 21:40 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-10 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:1e462fb480d38de5f9a4578bbe5c5bc66a01a9ed
commit r14-6381-g1e462fb480d38de5f9a4578bbe5c5bc66a01a9ed
Author: Harald Anlauf <anlauf@gmx.de>
Date: Wed Dec 6 20:42:27 2023 +0100
Fortran: function returning contiguous class array [PR105543]
gcc/fortran/ChangeLog:
PR fortran/105543
* resolve.cc (resolve_symbol): For a CLASS-valued function having a
RESULT clause, ensure that attr.class_ok is set for its symbol as
well as for its resolved result variable.
gcc/testsuite/ChangeLog:
PR fortran/105543
* gfortran.dg/contiguous_13.f90: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/105543] Function returning a class array with contiguous attribute rejected
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
` (3 preceding siblings ...)
2023-12-10 19:34 ` cvs-commit at gcc dot gnu.org
@ 2023-12-10 21:40 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-10 21:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-14. Thanks for the report!
The fix seems backportable. If needed, please inquire.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-10 21:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 6:02 [Bug fortran/105543] New: Function returning a class array with contiguous attribute rejected mscfd at gmx dot net
2022-05-10 18:28 ` [Bug fortran/105543] " anlauf at gcc dot gnu.org
2023-12-05 20:34 ` anlauf at gcc dot gnu.org
2023-12-06 20:33 ` anlauf at gcc dot gnu.org
2023-12-10 19:34 ` cvs-commit at gcc dot gnu.org
2023-12-10 21:40 ` anlauf 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).