From patchwork Sat Feb 12 11:20:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 82900 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 38547B7107 for ; Sat, 12 Feb 2011 22:21:10 +1100 (EST) Received: (qmail 28233 invoked by alias); 12 Feb 2011 11:21:06 -0000 Received: (qmail 28218 invoked by uid 22791); 12 Feb 2011 11:21:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 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; Sat, 12 Feb 2011 11:21:01 +0000 Received: from [192.168.178.22] (port-92-204-33-159.dynamic.qsc.de [92.204.33.159]) by mx01.qsc.de (Postfix) with ESMTP id 57DB53CB6B; Sat, 12 Feb 2011 12:20:58 +0100 (CET) Message-ID: <4D566D1A.5060404@net-b.de> Date: Sat, 12 Feb 2011 12:20:58 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR 45586: Correct access to parent components of DT on tree level 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 The issue was found by Michael when working on the "restrict" issue of DT; see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45586#c40 Without the patch, not only his draft patch fails, but one also gets - as Mikael pointed out - strange dumps. For extends_1.f03 the result without patch is: new_person->service.education.person.service.education.person.education.person.person.ss = *ss; with the patch the result is the more reasonable: new_person->service.education.person.ss = *ss; Build and regtested on x86-64-linux. OK for the trunk? Tobias PS: Michael plans to submit his restrict patch (comment 35) after this patch has been committed; the draft patch has been already pre-reviewed by Mikael (comment 38). 2011-02-12 Michael Matz Janus Weil Tobias Burnus PR fortran/45586 * trans-expr.c (conv_parent_component_references): Avoid unintendent skipping of parent compounds. diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index f19c015..b7d7ed9 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -538,6 +538,11 @@ conv_parent_component_references (gfc_se * se, gfc_ref * ref) dt = ref->u.c.sym; c = ref->u.c.component; + /* Return if the component is not in the parent type. */ + for (cmp = dt->components; cmp; cmp = cmp->next) + if (strcmp (c->name, cmp->name) == 0) + return; + /* Build a gfc_ref to recursively call gfc_conv_component_ref. */ parent.type = REF_COMPONENT; parent.next = NULL; @@ -547,23 +552,11 @@ conv_parent_component_references (gfc_se * se, gfc_ref * ref) if (dt->backend_decl == NULL) gfc_get_derived_type (dt); - if (dt->attr.extension && dt->components) - { - if (dt->attr.is_class) - cmp = dt->components; - else - cmp = dt->components->next; - /* Return if the component is not in the parent type. */ - for (; cmp; cmp = cmp->next) - if (strcmp (c->name, cmp->name) == 0) - return; - - /* Otherwise build the reference and call self. */ - gfc_conv_component_ref (se, &parent); - parent.u.c.sym = dt->components->ts.u.derived; - parent.u.c.component = c; - conv_parent_component_references (se, &parent); - } + /* Build the reference and call self. */ + gfc_conv_component_ref (se, &parent); + parent.u.c.sym = dt->components->ts.u.derived; + parent.u.c.component = c; + conv_parent_component_references (se, &parent); } /* Return the contents of a variable. Also handles reference/pointer