From patchwork Tue Jan 28 11:05:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1230296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518389-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=ecbj8K3z; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486P1M2Hprz9sNx for ; Tue, 28 Jan 2020 22:05:57 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=u4T0WMUS2NDAD/qwi+tRM5N/LaNUDumOGYcPDPh79cUNgAE3Kn z5Ry3ZzZpaAKxHRoQEdDdqbjbQksWI6RlXT60hMZWla4B181M0qtagSdu24XKSRk 3Q2f+HGHxJTPjvMeZO8eJu6oU+J1tJ2DVCKdBRpWz9hMZdJcYKTYY8D3Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=KSw1Hf60/CGWeFCRmcV7eCeD5fc=; b=ecbj8K3zlEIgkxmA+Gx+ zTcnAmx9HeUkxsYYEmtZNVWtC3RZIyskB/Wwxze9YYcEGd3sDde1AinHmnLwZ5C8 CVorX+czL6X7veh7iJPqwc/FYQ9ylwnIp/apKkMWz94WOQCjJP5IFQuSQ1zwaNrL CsosEEcOgmgziz7oq/t+RWo= Received: (qmail 61790 invoked by alias); 28 Jan 2020 11:05:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 61753 invoked by uid 89); 28 Jan 2020 11:05:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=nonARRAY_TYPE, sk:gfc_con, non-array_type, non-ARRAY_TYPE X-HELO: esa3.mentor.iphmx.com Received: from esa3.mentor.iphmx.com (HELO esa3.mentor.iphmx.com) (68.232.137.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jan 2020 11:05:37 +0000 IronPort-SDR: bcsTdvk4EMnwrxWRoOHtuP1suPgkZBOAlCYKj6LaFp8diCoOd3CJ3yPv/lpZXauSKIsMkYkyqF YIGlQTjZj3y2wRM/HiV+NAa4q15HN2/RhqsZ5J4X+TtwET5azKFWMM8qBmpLNbo/DGoHSETYtP uvAKLKlIOq6oC+2SoqVlz1TUkwXu6n93fjUKQCqVjnNvJTBPxn1j1Zkt9yUnOYOWsP6Oe6UTkR wMDUeD8hsD/gDhqB5Rs3RDy0Hc4xQxP2iQu1BoHFLGh35ZzkOqtFvN4Fw5XxC2iZWEha65Wo3s ALQ= Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 28 Jan 2020 03:05:36 -0800 IronPort-SDR: U4C9ubYV/MoB6mF8YuyovJ03AF7J8seYGYobwhbOY8IBadKwUiN0WWogUBlvavl0Cf1x0/Y6ti 0m4TFM9PWgMg== To: gcc-patches , fortran CC: Jakub Jelinek , Thomas Schwinge From: Tobias Burnus Subject: [Patch, committed][Fortran] avoid ICE in gfc_omp_check_optional_argument (PR93464) Message-ID: <6630bf5a-204e-be48-a6d8-645ccd2adc99@codesourcery.com> Date: Tue, 28 Jan 2020 12:05:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 X-IsSubscribed: yes (This was a GCC 10 regression, affecting both OpenMP and OpenACC.) In gfc_omp_check_optional_argument: DECL_LANG_SPECIFIC is always available (check at the top). However, if decl is not a PARM_DECL, it can have two reasons: Either it is no parameter (C sense; Fortran: dummy argument) at all or – as gfortran does for assumed-shape arrays – it is a locally defined decl which belongs to the array parameter. In the latter case, GFC_DECL_SAVED_DESCRIPTOR contains the actual PARAM_DECL. Well, as this test case shows, the GFC_DESCRIPTOR_TYPE_P condition is fulfilled, but as it is a locally defined variable, GFC_DECL_SAVED_DESCRIPTOR is NULL. The reason that it didn't show up before is that most of the local arrays do not have DECL_LANG_SPECIFIC – this one does because it is a character string (used for the string length). Applied as obvious after building and regtesting. Cheers, Tobias commit 627d59b6b3062de921fbdd80b2b48de18f599d03 Author: Tobias Burnus Date: Tue Jan 28 11:54:57 2020 +0100 [Fortran] avoid ICE in gfc_omp_check_optional_argument (PR93464) PR fortran/93464 * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars. PR fortran/93464 * gfortran.dg/goacc/pr93464.f90: New. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4040ff284b3..eb8842b0ab8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,9 +1,16 @@ +2020-01-28 Tobias Burnus + + PR fortran/93464 + * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when + DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not + GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars. + 2020-01-28 Tobias Burnus * gfortran.texi (Runtime): Remove tailing '.' in @menu. 2020-01-27 Tobias Burnus PR fortran/85781 * trans-expr.c (gfc_conv_substring): Handle non-ARRAY_TYPE strings of Bind(C) procedures. diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index fd60bbbed5d..66669550499 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -95,19 +95,20 @@ gfc_omp_check_optional_argument (tree decl, bool for_present_check) /* For assumed-shape arrays, a local decl with arg->data is used. */ if (TREE_CODE (decl) != PARM_DECL && (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)) || GFC_ARRAY_TYPE_P (TREE_TYPE (decl)))) { is_array_type = true; decl = GFC_DECL_SAVED_DESCRIPTOR (decl); } - if (TREE_CODE (decl) != PARM_DECL + if (decl == NULL_TREE + || TREE_CODE (decl) != PARM_DECL || !DECL_LANG_SPECIFIC (decl) || !GFC_DECL_OPTIONAL_ARGUMENT (decl)) return NULL_TREE; /* Scalars with VALUE attribute which are passed by value use a hidden argument to denote the present status. They are passed as nonpointer type with one exception: 'type(c_ptr), value' as 'void*'. */ /* Cf. trans-expr.c's gfc_conv_expr_present. */ if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eac18206b12..d9441cb0a2e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,9 +1,14 @@ +2020-01-28 Tobias Burnus + + PR fortran/93464 + * gfortran.dg/goacc/pr93464.f90: New. + 2020-01-28 Richard Sandiford PR tree-optimization/93434 * gcc.c-torture/execute/pr93434.c: New test. 2020-01-28 Richard Sandiford PR testsuite/93460 * gcc.dg/torture/pr93170.c: Add -Wpsabi. diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 new file mode 100644 index 00000000000..922106540f9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR fortran/93464 +! +! Contributed by G. Steinmetz +! +program p + character :: c(2) = 'a' + character, allocatable :: z(:) + !$acc parallel + !$omp target + z = c + !$acc end parallel + !$omp end target + print *, z +end