From patchwork Tue Jan 31 22:23:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 138871 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 7982FB6F98 for ; Wed, 1 Feb 2012 09:23:41 +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=1328653421; 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=HT4DJnG DS1YHb6UC9aV29YCWOT4=; b=Wycf/jI2jMVw4losfKCUC6dX88IJnLmGhCsrC8T yDcnCKJmNyVortUWksw8tb8lTxvomgXwG+z86yOZv4klBSGFSXBB4Gru/atoUGlH HULTYJR1C0R7OeQxGMr7sK9ykN6N/rkWlUEI2sEjdWNjI6K2+ZT2P7q1zwgR5m/2 5pGE= 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=THicMK4NnCQNthMGeVZk+gbkS3YHaKaozXSNDjMzcFnP0SVZ7twfH87J8Udm9K XFeyw2OHj98f5mtrvD9vuSbo1LYHnXZDuOy3QNm6ad5rLipfuFaLODoE49OsSS4D 4L0f8vYM1ZJVdqC5K0MxymvmnrfJsfSEETaaeQm1C67do=; Received: (qmail 3218 invoked by alias); 31 Jan 2012 22:23:29 -0000 Received: (qmail 3192 invoked by uid 22791); 31 Jan 2012 22:23:28 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_TB X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jan 2012 22:23:14 +0000 Received: from [192.168.178.22] (port-92-204-113-100.dynamic.qsc.de [92.204.113.100]) by mx02.qsc.de (Postfix) with ESMTP id C5D4F1E163; Tue, 31 Jan 2012 23:23:12 +0100 (CET) Message-ID: <4F2869D0.8070201@net-b.de> Date: Tue, 31 Jan 2012 23:23:12 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR 52024 - fix .mod issue with type-bound operator check 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 Dear all, my just committed patch which checks type-bound operators for ambiguity missed a handling of module files. The attached patch adds one. Unfortunately, it turns out that the check does not handle inheritance well. At least I would expect that the attached test case is valid (and it compiles with NAG 5.1), but it is rejected with GCC 4.6 and 4.7. Thus, I will keep the PR open such that we can deal with that issue later. Build and regtested on x86-64. OK for the trunk? Tobias 2012-01-31 Tobias Burnus PR fortran/52024 * module.c (MOD_VERSION): Bump. (mio_typebound_proc): Read/write is_operator from/to the .mod file. 2012-01-31 Tobias Burnus PR fortran/52024 * gfortran.dg/typebound_operator_14.f90: New. Index: gcc/fortran/module.c =================================================================== --- gcc/fortran/module.c (Revision 183775) +++ gcc/fortran/module.c (Arbeitskopie) @@ -74,21 +74,21 @@ along with GCC; see the file COPYING3. #include "parse.h" /* FIXME */ #include "md5.h" #include "constructor.h" #include "cpp.h" #include "tree.h" #define MODULE_EXTENSION ".mod" /* Don't put any single quote (') in MOD_VERSION, if yout want it to be recognized. */ -#define MOD_VERSION "8" +#define MOD_VERSION "9" /* Structure that describes a position within a module file. */ typedef struct { int column, line; fpos_t pos; } module_locus; @@ -3571,36 +3571,44 @@ mio_typebound_proc (gfc_typebound_proc** mio_pool_string (&((*proc)->pass_arg)); flag = (int) (*proc)->pass_arg_num; mio_integer (&flag); (*proc)->pass_arg_num = (unsigned) flag; if ((*proc)->is_generic) { gfc_tbp_generic* g; + int iop; mio_lparen (); if (iomode == IO_OUTPUT) for (g = (*proc)->u.generic; g; g = g->next) - mio_allocated_string (g->specific_st->name); + { + iop = (int) g->is_operator; + mio_integer (&iop); + mio_allocated_string (g->specific_st->name); + } else { (*proc)->u.generic = NULL; while (peek_atom () != ATOM_RPAREN) { gfc_symtree** sym_root; g = gfc_get_tbp_generic (); g->specific = NULL; + mio_integer (&iop); + g->is_operator = (bool) iop; + require_atom (ATOM_STRING); sym_root = ¤t_f2k_derived->tb_sym_root; g->specific_st = gfc_get_tbp_symtree (sym_root, atom_string); free (atom_string); g->next = (*proc)->u.generic; (*proc)->u.generic = g; } } Index: gcc/testsuite/gfortran.dg/typebound_operator_14.f90 =================================================================== --- gcc/testsuite/gfortran.dg/typebound_operator_14.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/typebound_operator_14.f90 (Arbeitskopie) @@ -0,0 +1,46 @@ +! { dg-do compile } +! +! PR fortran/52024 +! +! Contributed by Dominique d'Humieres +! +! FIXME: The following test case is valid but it is currently rejected. +! +! The test case was segfaulting before +! + +module m_sort + implicit none + type, abstract :: sort_t + contains + generic :: operator(.gt.) => gt_cmp + procedure :: gt_cmp + end type sort_t +contains + logical function gt_cmp(a,b) + class(sort_t), intent(in) :: a, b + gt_cmp = .true. + end function gt_cmp +end module + +module test + use m_sort + implicit none + type, extends(sort_t) :: sort_int_t + integer :: i + contains ! FIXME: The following is actually not true: + generic :: operator(.gt.) => gt_cmp_int ! { dg-error "are ambiguous" } + procedure :: gt_cmp_int + end type +contains + logical function gt_cmp_int(a,b) result(cmp) + class(sort_int_t), intent(in) :: a, b + if (a%i > b%i) then + cmp = .true. + else + cmp = .false. + end if + end function gt_cmp_int +end module + +! { dg-final { cleanup-tree-dump "m_sort test" } }