[Bug fortran/105543] Function returning a class array with contiguous attribute rejected
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.
[Bug fortran/105543] Function returning a class array with contiguous attribute rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105543 --- Comment #4 from GCC Commits --- The master branch has been updated by Harald Anlauf : https://gcc.gnu.org/g:1e462fb480d38de5f9a4578bbe5c5bc66a01a9ed commit r14-6381-g1e462fb480d38de5f9a4578bbe5c5bc66a01a9ed Author: Harald Anlauf 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.
[Bug fortran/105543] Function returning a class array with contiguous attribute rejected
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/05.html
[Bug fortran/105543] Function returning a class array with contiguous attribute rejected
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...
[Bug fortran/105543] Function returning a class array with contiguous attribute rejected
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.