From patchwork Wed Aug 14 04:23:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 1146734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-506866-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=troutmask.apl.washington.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SnmeP9XW"; 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 467c0Q48Ldz9sDQ for ; Wed, 14 Aug 2019 14:23:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=GfjZlosKhtU0t88jlj1Fuw7p7IAzV4+awexmGaulGu9 6BUtVlDscgAZiQXpronqD2W6l68ME/Hv0kQsglinrsaPP2OY3X5LsJc4Mb98MZKB 4Y//6EaFycbvHQGTRW7XlmYXrQQe0v/koMhKZZCdYhDrSeI5tR+kVhOVUNdItwek = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=fivGLku3zYgDW3TU7bdhVJXcsq0=; b=SnmeP9XWFUpFISSFW 6LOFwIOWqG2tI8MmTFDha7sEnw67RliI4a8xNxYmy8pqvxHeVhQirfq6WRNeeAJx OCmnH6Rs71qUBDuNiSoZqn62SwDMYEPifSj5atLlM4C98vas+Cj0nutmvJ+eHI2w 4v+c0+QTqvgmPMuu80STrAcJMg= Received: (qmail 17665 invoked by alias); 14 Aug 2019 04:23:39 -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 17650 invoked by uid 89); 14 Aug 2019 04:23:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS autolearn=ham version=3.3.1 spammy= X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Aug 2019 04:23:37 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id x7E4NZKK095803 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 13 Aug 2019 21:23:36 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id x7E4NZdt095802; Tue, 13 Aug 2019 21:23:35 -0700 (PDT) (envelope-from sgk) Date: Tue, 13 Aug 2019 21:23:35 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/87991 -- Pointer data object requires a target Message-ID: <20190814042335.GA95792@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Committed as obviously. 2019-08-13 Steven G. Kargl PR fortran/87991 * resolve.c (check_data_variable): data-stmt-object with pointer attribute requires a data-stmt-value with the target attribute. 2019-08-13 Steven G. Kargl PR fortran/87991 * gfortran.dg/pr87991.f90: New test. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 274398) +++ gcc/fortran/resolve.c (working copy) @@ -15726,8 +15726,6 @@ check_data_variable (gfc_data_variable *var, locus *wh return false; } - has_pointer = sym->attr.pointer; - if (gfc_is_coindexed (e)) { gfc_error ("DATA element %qs at %L cannot have a coindex", sym->name, @@ -15735,19 +15733,30 @@ check_data_variable (gfc_data_variable *var, locus *wh return false; } + has_pointer = sym->attr.pointer; + for (ref = e->ref; ref; ref = ref->next) { if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer) has_pointer = 1; - if (has_pointer - && ref->type == REF_ARRAY - && ref->u.ar.type != AR_FULL) - { - gfc_error ("DATA element %qs at %L is a pointer and so must " - "be a full array", sym->name, where); - return false; - } + if (has_pointer) + { + if (ref->type == REF_ARRAY && ref->u.ar.type != AR_FULL) + { + gfc_error ("DATA element %qs at %L is a pointer and so must " + "be a full array", sym->name, where); + return false; + } + + if (values.vnode->expr->expr_type == EXPR_CONSTANT) + { + gfc_error ("DATA object near %L has the pointer attribute " + "and the corresponding DATA value is not a valid " + "initial-data-target", where); + return false; + } + } } if (e->rank == 0 || has_pointer) Index: gcc/testsuite/gfortran.dg/pr87991.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr87991.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr87991.f90 (working copy) @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-w" } +! PR fortran/87991 +program p + type t + character(:), pointer :: c + end type + type(t) :: x + allocate (character(3) :: x%c) + data x%c /'abc'/ ! { dg-error "has the pointer attribute" } +end