From patchwork Tue Apr 3 11:59:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 150408 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 BC10FB707A for ; Tue, 3 Apr 2012 21:59:48 +1000 (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=1334059190; 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=cZtQ3H5 RRukRI2j0wR2ztZ5ZPG4=; b=B3tqFpTWDY8aHazE8nylxVpkD328V0pb8VoQeTI M1pCU79xCFOykYdUQKIXOs6Rb9Hq/XWF/8j9KzBhaVJwT9s8QODa1HpJNl+OMq2C QWCw2nLvmAVkSx/jGISwOXcyJmK7cqhJVQSbzxUVOVsqirK4mDKPyWbSDXtY52c5 8hAI= 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=cQWFjhFM2QCaG3jsOEheJVMv1MSgk/d8hsv8CmXtqXw/ICGTrUqWzJHmtO0KGL aKK0eNdwNa+9yZ/zUj/iaU6CziFAktpsJaFXT7Bkp6YAXpvtKuzoLR9hDJKUQWEE 3hZQBVluPYZMoKGXPeobo+JntVxMuIWRfpswyMzG1XfWg=; Received: (qmail 22122 invoked by alias); 3 Apr 2012 11:59:44 -0000 Received: (qmail 22107 invoked by uid 22791); 3 Apr 2012 11:59:43 -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 mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Apr 2012 11:59:29 +0000 Received: from [192.168.178.22] (port-92-204-93-154.dynamic.qsc.de [92.204.93.154]) by mx02.qsc.de (Postfix) with ESMTP id EE5F21E9C0; Tue, 3 Apr 2012 13:59:16 +0200 (CEST) Message-ID: <4F7AE611.9090209@net-b.de> Date: Tue, 03 Apr 2012 13:59:13 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR52729 - fix module-proc decl access for BLOCK/SELECT TYPE 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 A rather obvious patch. The module procedure had the FL_PROCEDURE due its use ("CALL sub" or "func()") - but no interface and no type. Thus, there was no attempt to search for the symbol in the parent namespace, which causes failures. Build and tested on x86-84-linux. OK for the trunk? Tobias PS: I lost track. Are there patches which still have to be reviewed? 2012-04-03 Tobias Burnus PR fortran/52729 * resolve.c (resolve_symbol): Fix searching for parent NS decl. 2012-04-03 Tobias Burnus PR fortran/52729 * gfortran.dg/block_11.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index b63a0c6..910d322 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12246,7 +12277,10 @@ resolve_symbol (gfc_symbol *sym) symbol_attribute class_attr; gfc_array_spec *as; - if (sym->attr.flavor == FL_UNKNOWN) + if (sym->attr.flavor == FL_UNKNOWN + || (sym->attr.flavor == FL_PROCEDURE && !sym->attr.intrinsic + && !sym->attr.generic && !sym->attr.external + && sym->attr.if_source == IFSRC_UNKNOWN)) { /* If we find that a flavorless symbol is an interface in one of the @@ -12270,9 +12303,10 @@ resolve_symbol (gfc_symbol *sym) /* Otherwise give it a flavor according to such attributes as it has. */ - if (sym->attr.external == 0 && sym->attr.intrinsic == 0) + if (sym->attr.flavor == FL_UNKNOWN && sym->attr.external == 0 + && sym->attr.intrinsic == 0) sym->attr.flavor = FL_VARIABLE; - else + else if (sym->attr.flavor == FL_UNKNOWN) { sym->attr.flavor = FL_PROCEDURE; if (sym->attr.dimension) --- /dev/null 2012-03-22 21:06:43.387787737 +0100 +++ gcc/gcc/testsuite/gfortran.dg/block_11.f90 2012-04-03 10:52:27.000000000 +0200 @@ -0,0 +1,68 @@ +! { dg-do link } +! +! PR fortran/52729 +! +! Based on a contribution of Andrew Benson +! +module testMod + type testType + end type testType +contains + subroutine testSub() + implicit none + procedure(double precision ), pointer :: r + class (testType ), pointer :: testObject + double precision :: testVal + + ! Failed as testFunc was BT_UNKNOWN + select type (testObject) + class is (testType) + testVal=testFunc() + r => testFunc + end select + return + end subroutine testSub + + double precision function testFunc() + implicit none + return + end function testFunc +end module testMod + +module testMod2 + implicit none +contains + subroutine testSub() + procedure(double precision ), pointer :: r + double precision :: testVal + ! Failed as testFunc was BT_UNKNOWN + block + r => testFunc + testVal=testFunc() + end block + end subroutine testSub + + double precision function testFunc() + end function testFunc +end module testMod2 + +module m3 + implicit none +contains + subroutine my_test() + procedure(), pointer :: ptr + ! Before the fix, one had the link error + ! "undefined reference to `sub.1909'" + block + ptr => sub + call sub() + end block + end subroutine my_test + subroutine sub(a) + integer, optional :: a + end subroutine sub +end module m3 + +end + +! { dg-final { cleanup-modules "testmod testmod2 m3" } }