From patchwork Tue Jun 28 15:40:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 102410 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 8C062B6F69 for ; Wed, 29 Jun 2011 01:41:01 +1000 (EST) Received: (qmail 15421 invoked by alias); 28 Jun 2011 15:40:56 -0000 Received: (qmail 15404 invoked by uid 22791); 28 Jun 2011 15:40:55 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Jun 2011 15:40:40 +0000 Received: by gxk3 with SMTP id 3so136038gxk.20 for ; Tue, 28 Jun 2011 08:40:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.26.15 with SMTP id d15mr8182028ybj.318.1309275639404; Tue, 28 Jun 2011 08:40:39 -0700 (PDT) Received: by 10.147.98.13 with HTTP; Tue, 28 Jun 2011 08:40:39 -0700 (PDT) Date: Tue, 28 Jun 2011 17:40:39 +0200 Message-ID: Subject: [Patch, Fortran, F08] PR 49562: [4.6/4.7 Regression] [OOP] assigning value to type-bound function 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, here is a patch for a problem which was originally reported as an ICE-on-invalid regression (assigning to a type-bound function). In the course of fixing it, I noticed that it becomes valid according to F08 if the function is pointer-valued, and modified the patch such that it will accept this variant. I also adapted the original test case to be a run-time test of this F08 feature (in fact it is just a very complicated way of performing an increment from 0 to 1, and would still segfault without the patch). The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.6.2? Cheers, Janus 2011-06-28 Janus Weil PR fortran/49562 * expr.c (gfc_check_vardef_context): Handle type-bound procedures. 2011-06-28 Janus Weil PR fortran/49562 * gfortran.dg/typebound_proc_23.f90: New. Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 175580) +++ gcc/fortran/expr.c (working copy) @@ -4394,8 +4394,8 @@ gfc_check_vardef_context (gfc_expr* e, bool pointe sym = e->value.function.esym ? e->value.function.esym : e->symtree->n.sym; } - if (!pointer && e->expr_type == EXPR_FUNCTION - && sym->result->attr.pointer) + attr = gfc_expr_attr (e); + if (!pointer && e->expr_type == EXPR_FUNCTION && attr.pointer) { if (!(gfc_option.allow_std & GFC_STD_F2008)) { @@ -4432,7 +4432,6 @@ gfc_check_vardef_context (gfc_expr* e, bool pointe /* Find out whether the expr is a pointer; this also means following component references to the last one. */ - attr = gfc_expr_attr (e); is_pointer = (attr.pointer || attr.proc_pointer); if (pointer && !is_pointer) {