From patchwork Tue Apr 16 14:17:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 236977 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A755A2C0194 for ; Wed, 17 Apr 2013 00:17:51 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=YC9Oa+z0d7DBf/tc8NWw+Tn+vx3qNCbVoRlssuvHpedx8m vG1Do1Q3qeyUhJek0tDhgwUllERC3GUvb7pdzmltcitVO37bBSDbVqit3rpx+vYe 894xtbphEQBBUcx71jzNm26UnYSwk6d4QSL+qpNHDWTfKh30+AL95TLsGbtmo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=LJGhWgmfExUKXSFyP7q7Mzt2GNc=; b=RXMH8phh+QzZQx65TDfV bc7t3FntFKKf5zC/X0tzlltovtCWErYlqKX1r+tqJXFB0lRubeKwbQ3LNwLrU9HQ ah1qW4s/eBmHtgZeWnFK2s31v9JQXHStI41TXFH2thpriDFrhGO8O6HiCBmSR52J zTl/eNWCiuxTNEU4XXQs80g= Received: (qmail 4891 invoked by alias); 16 Apr 2013 14:17:44 -0000 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 Received: (qmail 4872 invoked by uid 89); 16 Apr 2013 14:17:43 -0000 X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 16 Apr 2013 14:17:42 +0000 Received: from archimedes.net-b.de (port-92-195-195-180.dynamic.qsc.de [92.195.195.180]) by mx02.qsc.de (Postfix) with ESMTP id B74E3276A8; Tue, 16 Apr 2013 16:17:39 +0200 (CEST) Message-ID: <516D5D82.3000206@net-b.de> Date: Tue, 16 Apr 2013 16:17:38 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran, comitted] PR56969 - Fix bogus ambiguous symbol error for ISO_C_Binding intrinsics X-Virus-Found: No The problem was that C_ASSOCIATED was made available multiple times. As gfc_intrinsic_func_interface calls gfc_intrinsic_symbol, the sym->module was set to "(intrinsic)" which didn't match the original "__iso_c_binding". Hence, the symbols weren't recognized as the same and an error is printed. I have commit the attached patch as obvious, after a successful built and regtesting on x86-64-gnu-linux. Rev. 198000. Tobias 2013-04-16 Tobias Burnus PR fortran/56969 * intrinsic.c (gfc_intrinsic_func_interface): Don't set module name to "(intrinsic)" for intrinsics from intrinsic modules. 2013-04-16 Tobias Burnus PR fortran/56969 * gfortran.dg/c_assoc_5.f90: New. diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index c431279..688332f 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4236,7 +4236,8 @@ gfc_intrinsic_func_interface (gfc_expr *expr, int error_flag) got_specific: expr->value.function.isym = specific; - gfc_intrinsic_symbol (expr->symtree->n.sym); + if (!expr->symtree->n.sym->module) + gfc_intrinsic_symbol (expr->symtree->n.sym); if (!error_flag) gfc_pop_suppress_errors (); --- /dev/null 2013-04-16 09:37:35.264983505 +0200 +++ gcc/gcc/testsuite/gfortran.dg/c_assoc_5.f90 2013-04-16 13:31:04.335893680 +0200 @@ -0,0 +1,69 @@ +! { dg-do compile } +! +! PR fortran/56969 +! +! Contributed by Salvatore Filippone +! +! Was before rejected as the different c_associated weren't recognized to +! come from the same module. +! +module test_mod + use iso_c_binding + + type(c_ptr), save :: test_context = c_null_ptr + + type, bind(c) :: s_Cmat + type(c_ptr) :: Mat = c_null_ptr + end type s_Cmat + + + interface + function FtestCreate(context) & + & bind(c,name="FtestCreate") result(res) + use iso_c_binding + type(c_ptr) :: context + integer(c_int) :: res + end function FtestCreate + end interface +contains + + function initFtest() result(res) + implicit none + integer(c_int) :: res + if (c_associated(test_context)) then + res = 0 + else + res = FtestCreate(test_context) + end if + end function initFtest +end module test_mod + +module base_mat_mod + type base_sparse_mat + integer, allocatable :: ia(:) + end type base_sparse_mat +end module base_mat_mod + +module extd_mat_mod + + use iso_c_binding + use test_mod + use base_mat_mod + + type, extends(base_sparse_mat) :: extd_sparse_mat + type(s_Cmat) :: deviceMat + end type extd_sparse_mat + +end module extd_mat_mod + +subroutine extd_foo(a) + + use extd_mat_mod + implicit none + class(extd_sparse_mat), intent(inout) :: a + + if (c_associated(a%deviceMat%Mat)) then + write(*,*) 'C Associated' + end if + +end subroutine extd_foo