From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A0E203858C54; Sun, 18 Sep 2022 19:11:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0E203858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663528319; bh=o8sTEps+SXUvZ38DUUwWtvU1SsCxdWVQ5n/pIGY29N0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VNHPp01cjaA8AIH/Jqj7ZI/z7Ko3jZw6X0EgGU+SL9BH1YAoC0IWZpq/5q8XT56x/ CTDq7p8BUN/TlJLEKilL6WfZgeeZjrVpAHPT17VmBu7DUrLW6f6b+Umh6S/eqO+fjN 2y1mN7f54q8FrTlNlE8K2KMfbR5AI/+vdYvmOUeM= From: "anlauf at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/100132] Optimization breaks pointer association Date: Sun, 18 Sep 2022 19:11:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: anlauf at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jrfsousa at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100132 anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #3 from anlauf at gcc dot gnu.org --- (In reply to Jos=C3=A9 Rui Faustino de Sousa from comment #1) > Patch posted >=20 > https://gcc.gnu.org/pipermail/fortran/2021-April/055946.html The patch is technically fine and regtests ok, but was unfortunately never reviewed. The basic fix can be slightly shortened to: diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 0ea7c74a6f1..c062a5b29d7 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -3054,12 +3054,23 @@ create_fn_spec (gfc_symbol *sym, tree fntype) for (f =3D gfc_sym_get_dummy_args (sym); f; f =3D f->next) if (spec_len < sizeof (spec)) { - if (!f->sym || f->sym->attr.pointer || f->sym->attr.target + bool is_class =3D false; + bool is_pointer =3D false; + + if (f->sym) + { + is_class =3D f->sym->ts.type =3D=3D BT_CLASS && CLASS_DATA (f->= sym) + && f->sym->attr.class_ok; + is_pointer =3D is_class ? CLASS_DATA (f->sym)->attr.class_point= er + : f->sym->attr.pointer; + } + + if (f->sym =3D=3D NULL || is_pointer || f->sym->attr.target || f->sym->attr.external || f->sym->attr.cray_pointer || (f->sym->ts.type =3D=3D BT_DERIVED && (f->sym->ts.u.derived->attr.proc_pointer_comp || f->sym->ts.u.derived->attr.pointer_comp)) - || (f->sym->ts.type =3D=3D BT_CLASS + || (is_class && (CLASS_DATA (f->sym)->ts.u.derived->attr.proc_pointer_co= mp || CLASS_DATA (f->sym)->ts.u.derived->attr.pointer_comp= )) || (f->sym->ts.type =3D=3D BT_INTEGER && f->sym->ts.is_c_intero= p)) I can take care of it for you.=