From patchwork Sat Dec 27 17:35:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 424237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 8D7C81400DE for ; Sun, 28 Dec 2014 04:35:43 +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 :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=eHl0T0BAAe8lFqENsCWR6Ktahul4WoZJPv2opz4R+/qroP eaQ6/aLoWG3nWFdPhG5MEsy7TASnUFkFdZ7SsQMsE4zBLsyKQbCUzRR4GapltPGr 2PRcRSjsxC4B5c6pKMmgFn7iblFX4OVHToLrsONKyWgwuKP5LRspIXK7XCNZM= 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 :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=yV1py52/IbAgCkNKnbE8z1jHjNI=; b=ytNwj74ZxMskcltew1P4 nMlU8Y0S97w+IHDEMb/sYPXWP5O9go3cqJKg/jC7Fmzcv7yCKpxa05IFrIZdn7FP PmGzueJ9715AYXBHDJtFvSVdgMSROXMYufrbZ+3b+XltOOrY5erZe5Lt940h7rMI Bd4qKAsC9tF1JmdOGkZR/AM= Received: (qmail 32492 invoked by alias); 27 Dec 2014 17:35:22 -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 32383 invoked by uid 89); 27 Dec 2014 17:35:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-qc0-f174.google.com Received: from mail-qc0-f174.google.com (HELO mail-qc0-f174.google.com) (209.85.216.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 27 Dec 2014 17:35:19 +0000 Received: by mail-qc0-f174.google.com with SMTP id c9so8081663qcz.19; Sat, 27 Dec 2014 09:35:17 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.3.137 with SMTP id 9mr79257603qan.64.1419701717207; Sat, 27 Dec 2014 09:35:17 -0800 (PST) Received: by 10.96.211.7 with HTTP; Sat, 27 Dec 2014 09:35:17 -0800 (PST) Date: Sat, 27 Dec 2014 18:35:17 +0100 Message-ID: Subject: [Patch, Fortran, F08] PR 60357: structure constructor with unspecified values for allocatable components From: Janus Weil To: gfortran , gcc-patches Hi all, here is a small patch for an F08 extension: Allocatable components don't have to be specified in structure constructors any more. Regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 2014-12-27 Janus Weil PR fortran/60357 * array.c (check_constructor): Ignore empty expressions. * expr.c (check_alloc_comp_init): Check if constructor expression exists. * primary.c (build_actual_constructor): Warn for absent alloc-comp initializers in pre-2008 standards. 2014-12-27 Janus Weil PR fortran/60357 * gfortran.dg/alloc_comp_constructor_7.f90: New. Index: gcc/fortran/array.c =================================================================== --- gcc/fortran/array.c (Revision 219082) +++ gcc/fortran/array.c (Arbeitskopie) @@ -1309,6 +1309,9 @@ check_constructor (gfc_constructor_base ctor, bool { e = c->expr; + if (!e) + continue; + if (e->expr_type != EXPR_ARRAY) { if (!(*check_function)(e)) Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (Revision 219082) +++ gcc/fortran/expr.c (Arbeitskopie) @@ -2201,7 +2201,7 @@ check_alloc_comp_init (gfc_expr *e) ctor = gfc_constructor_first (e->value.constructor); comp; comp = comp->next, ctor = gfc_constructor_next (ctor)) { - if (comp->attr.allocatable + if (comp->attr.allocatable && ctor->expr && ctor->expr->expr_type != EXPR_NULL) { gfc_error ("Invalid initialization expression for ALLOCATABLE " Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (Revision 219082) +++ gcc/fortran/primary.c (Arbeitskopie) @@ -2367,6 +2367,13 @@ build_actual_constructor (gfc_structure_ctor_compo return false; value = gfc_copy_expr (comp->initializer); } + else if (comp->attr.allocatable) + { + if (!gfc_notify_std (GFC_STD_F2008, "No initializer for " + "allocatable component '%s' given in the structure " + "constructor at %C", comp->name)) + return false; + } else if (!comp->attr.deferred_parameter) { gfc_error ("No initializer for component %qs given in the"