From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65006 invoked by alias); 6 Dec 2018 23:31:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64895 invoked by uid 89); 6 Dec 2018 23:31:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=6677 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Dec 2018 23:31:19 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0E7EC070460; Thu, 6 Dec 2018 23:31:11 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-214.ams2.redhat.com [10.36.117.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82CD579D48; Thu, 6 Dec 2018 23:31:11 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id wB6NV9DL016148; Fri, 7 Dec 2018 00:31:09 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wB6NV8KX016147; Fri, 7 Dec 2018 00:31:08 +0100 Date: Thu, 06 Dec 2018 23:31:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [committed] Fix OpenMP handling of character allocatable scalars (PR fortran/88377) Message-ID: <20181206233108.GA12380@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00417.txt.bz2 Hi! Apparently the length decls corresponding to allocatable scalars with character type are also GFC_DECL_GET_SCALAR_ALLOCATABLE; the OpenMP clause handling code was relying on those to have POINTER_TYPEs, but the lengths are integrals and should be handled normally. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2018-12-07 Jakub Jelinek PR fortran/88377 * trans-openmp.c (gfc_omp_clause_default_ctor, gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op, gfc_omp_clause_linear_ctor, gfc_omp_clause_dtor): Only consider GFC_DECL_GET_SCALAR_ALLOCATABLE vars as scalar allocatables if they have pointer type. * gfortran.dg/gomp/pr88377.f90: New test. --- gcc/fortran/trans-openmp.c.jj 2018-11-08 18:07:56.253072145 +0100 +++ gcc/fortran/trans-openmp.c 2018-12-06 15:58:54.647301230 +0100 @@ -460,7 +460,8 @@ gfc_omp_clause_default_ctor (tree clause if ((! GFC_DESCRIPTOR_TYPE_P (type) || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE) - && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))) + && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)) + || !POINTER_TYPE_P (type))) { if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause))) { @@ -567,7 +568,8 @@ gfc_omp_clause_copy_ctor (tree clause, t if ((! GFC_DESCRIPTOR_TYPE_P (type) || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE) - && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))) + && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)) + || !POINTER_TYPE_P (type))) { if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause))) { @@ -667,7 +669,8 @@ gfc_omp_clause_assign_op (tree clause, t if ((! GFC_DESCRIPTOR_TYPE_P (type) || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE) - && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))) + && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)) + || !POINTER_TYPE_P (type))) { if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause))) { @@ -905,7 +908,8 @@ gfc_omp_clause_linear_ctor (tree clause, if ((! GFC_DESCRIPTOR_TYPE_P (type) || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE) - && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))) + && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)) + || !POINTER_TYPE_P (type))) { gcc_assert (TREE_CODE (type) == ARRAY_TYPE); if (!TYPE_DOMAIN (type) @@ -989,7 +993,8 @@ gfc_omp_clause_dtor (tree clause, tree d if ((! GFC_DESCRIPTOR_TYPE_P (type) || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE) - && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))) + && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)) + || !POINTER_TYPE_P (type))) { if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause))) return gfc_walk_alloc_comps (decl, NULL_TREE, --- gcc/testsuite/gfortran.dg/gomp/pr88377.f90.jj 2018-12-06 16:00:28.779775783 +0100 +++ gcc/testsuite/gfortran.dg/gomp/pr88377.f90 2018-12-06 16:00:02.714198182 +0100 @@ -0,0 +1,15 @@ +! PR fortran/88377 +! { dg-do compile } + +program pr88377 + call s(3) +contains + subroutine s(n) + integer :: n + character(n), allocatable :: x + x = 'abc' + !$omp task + print *, x, (x == 'abc') + !$omp end task + end +end Jakub