This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, Fortran] PR63861 - fix OpenMP/ACC's gfc_has_alloc_comps
- From: Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org, Jakub Jelinek <jakub at redhat dot com>, Cesar Philippidis <cesar at codesourcery dot com>
- Date: Mon, 26 Jan 2015 13:14:39 +0100
- Subject: Re: [Patch, Fortran] PR63861 - fix OpenMP/ACC's gfc_has_alloc_comps
- Authentication-results: sourceware.org; auth=none
Dear all,
I wrote:
> - while (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type))
> + if (GFC_DESCRIPTOR_TYPE_P (type)
> + || (GFC_ARRAY_TYPE_P (type) && GFC_TYPE_ARRAY_RANK (type) == 0))
That's nonsense: It should be "!= 0". If one has an array type which has
a rank > 0 (i.e. it is not a scalar coarray), it shall get the element type.
The == 0 got muddled in because I couldn't decide whether it should be
"while" -> "if", i.e.
if (GFC_DESCRIPTOR_TYPE_P (type) || GFC_ARRAY_TYPE_P (type))
type = gfc_get_element_type (type);
or remain "while" with an added rank != 0 check, i.e.
while (GFC_DESCRIPTOR_TYPE_P (type)
|| (GFC_ARRAY_TYPE_P (type) && GFC_TYPE_ARRAY_RANK (type) != 0))
type = gfc_get_element_type (type);
Both should works as gfc_get_element_type() return for scalar coarrays
of type GFC_ARRAY_TYPE_P() the unmodified argument.
The question is why I didn't see the nonsense in the test suite. It
doesn't seem to be tested for in gcc/testsuite/gfortran.dg/; it might be
tested in libgomp/testsuite/ - I don't recall whether I retested after
the (incomplete) change back from "if" to "while" + (wrong) rank check.
Jakub: It should show up in a test in libgomp/testsuite/, shouldn't it?
Jakub: Do you know why you used a WHILE and not a simple IF? I tried
to come up with a case where the element type is an array, but I failed.
All: Any preference for "if" or "while" + rank != 0?
Tobias