From patchwork Fri Dec 21 21:41:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 207879 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]) by ozlabs.org (Postfix) with SMTP id 4F41F2C008A for ; Sat, 22 Dec 2012 08:41:56 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1356730916; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=5MUezPy Uc0Jxg76BD3ny32CUacM=; b=kBahzk5pWs5+Mkayzov4VkiyZVLsFlhseiBlCfd QqwoDGKbmjqf4l4HG9HAr1AXC3b7WbI7ob1i5PCQs7LoCHwjIcVZExLRHkTZgGg3 FERsOAoI+VjUBqNu1WpF9YIjJyZrdkyJw+15xFdxi8dmyxInboXH3mz6ycW3PeLr SFdU= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=OownXgc+Dg6wtJnN+8k1x0RvzC+P693yr1nqkgKZSE+EUSK5IuIMXhNHL4w4eU EAMlgjKRP56rZcREl3zkbH6yviQuNu4XA36wB9nDaZnZN0SCJOsQ7BEm9DPEOhDY lSfxGxS0HTAbnM8W5xoLHRCVqhpCU/Rahp/AeHptrTBR4=; Received: (qmail 23902 invoked by alias); 21 Dec 2012 21:41:49 -0000 Received: (qmail 23883 invoked by uid 22791); 21 Dec 2012 21:41:48 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Dec 2012 21:41:42 +0000 Received: from archimedes.net-b.de (port-92-195-64-88.dynamic.qsc.de [92.195.64.88]) by mx01.qsc.de (Postfix) with ESMTP id B05733D0F7; Fri, 21 Dec 2012 22:41:40 +0100 (CET) Message-ID: <50D4D794.9030003@net-b.de> Date: Fri, 21 Dec 2012 22:41:40 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR55763 fix .mod reading plus CALL with CLASS(*) 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 Another two fixes for CLASS(*). (We really should audit all calls to gfc_find_derived_vtab for possible issues with CLASS(*).) If I haven't miscounted, there is still one other failure in the PR. Build and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2012-12-21 Tobias Burnus PR fortran/55763 * module.c (mio_component): Don't skip _hash's initializer. * resolve.c (resolve_select_type): Add an assert. * trans-expr.c (gfc_conv_procedure_call): Handle INTENT(OUT) for UNLIMIT_POLY. 2012-12-21 Tobias Burnus PR fortran/55763 * gfortran.dg/unlimited_polymorphic_6.f90: New. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 168f933..a797f24 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2603,7 +2603,8 @@ mio_component (gfc_component *c, int vtype) c->attr.class_ok = 1; c->attr.access = MIO_NAME (gfc_access) (c->attr.access, access_types); - if (!vtype || strcmp (c->name, "_final") == 0) + if (!vtype || strcmp (c->name, "_final") == 0 + || strcmp (c->name, "_hash") == 0) mio_expr (&c->initializer); if (c->attr.proc_pointer) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index fce6f73..cf130a3 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8484,7 +8511,7 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) gfc_expr *e; ivtab = gfc_find_intrinsic_vtab (&c->ts); - gcc_assert (ivtab); + gcc_assert (ivtab && CLASS_DATA (ivtab)->initializer); e = CLASS_DATA (ivtab)->initializer; c->low = c->high = gfc_copy_expr (e); } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index ad26684..452f2bc 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -4302,7 +4302,14 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, null_pointer_node); gfc_add_expr_to_block (&block, tmp); - if (fsym->ts.type == BT_CLASS) + if (fsym->ts.type == BT_CLASS && UNLIMITED_POLY (fsym)) + { + gfc_add_modify (&block, ptr, + fold_convert (TREE_TYPE (ptr), + null_pointer_node)); + gfc_add_expr_to_block (&block, tmp); + } + else if (fsym->ts.type == BT_CLASS) { gfc_symbol *vtab; vtab = gfc_find_derived_vtab (fsym->ts.u.derived); diff --git a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_6.f90 b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_6.f90 new file mode 100644 index 0000000..a64f4e3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_6.f90 @@ -0,0 +1,37 @@ +! { dg-do run } +! +! PR fortran/55763 +! +! Contributed by Reinhold Bader +! +module mod_alloc_scalar_01 +contains + subroutine construct(this) + class(*), allocatable, intent(out) :: this + integer :: this_i + this_i = 4 + allocate(this, source=this_i) + end subroutine +end module + +program alloc_scalar_01 + use mod_alloc_scalar_01 + implicit none + class(*), allocatable :: mystuff + + call construct(mystuff) + call construct(mystuff) + + select type(mystuff) + type is (integer) + if (mystuff == 4) then +! write(*,*) 'OK' + else + call abort() +! write(*,*) 'FAIL 1' + end if + class default + call abort() +! write(*,*) 'FAIL 2' + end select +end program