From patchwork Sat Mar 12 11:16:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 86491 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 24CBDB6F01 for ; Sat, 12 Mar 2011 22:16:50 +1100 (EST) Received: (qmail 18398 invoked by alias); 12 Mar 2011 11:16:46 -0000 Received: (qmail 18382 invoked by uid 22791); 12 Mar 2011 11:16:45 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 12 Mar 2011 11:16:40 +0000 Received: by wwj40 with SMTP id 40so3571936wwj.8 for ; Sat, 12 Mar 2011 03:16:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.182.212 with SMTP id o62mr452647wem.52.1299928598166; Sat, 12 Mar 2011 03:16:38 -0800 (PST) Received: by 10.216.153.102 with HTTP; Sat, 12 Mar 2011 03:16:38 -0800 (PST) Date: Sat, 12 Mar 2011 12:16:38 +0100 Message-ID: Subject: [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type From: Janus Weil To: gfortran , gcc-patches 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 Hi all, the attached patch fixes the PR in the subject line. The problem was the following: During the interface mapping for a procedure call we need to take special care of polymorphic arguments, since the type of the actual argument can differ from the type of the formal argument. Therefore we need to replace the base type of component references by the actual type (in particular to get parent references right). The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 2011-03-12 Janus Weil PR fortran/48059 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Replace base type for polymorphic arguments. 2011-03-12 Janus Weil PR fortran/48059 * gfortran.dg/class_41.f03: New. Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (revision 170879) +++ gcc/fortran/trans-expr.c (working copy) @@ -2247,6 +2247,10 @@ gfc_apply_interface_mapping_to_expr (gfc_interface expr->symtree = sym->new_sym; else if (sym->expr) gfc_replace_expr (expr, gfc_copy_expr (sym->expr)); + /* Replace base type for polymorphic arguments. */ + if (expr->ref && expr->ref->type == REF_COMPONENT + && sym->expr && sym->expr->ts.type == BT_CLASS) + expr->ref->u.c.sym = sym->expr->ts.u.derived; } /* ...and to subexpressions in expr->value. */