From patchwork Tue Feb 22 19:15:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 83992 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 A391BB711D for ; Wed, 23 Feb 2011 06:15:46 +1100 (EST) Received: (qmail 15207 invoked by alias); 22 Feb 2011 19:15:40 -0000 Received: (qmail 15180 invoked by uid 22791); 22 Feb 2011 19:15:39 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-bw0-f48.google.com (HELO mail-bw0-f48.google.com) (209.85.214.48) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Feb 2011 19:15:34 +0000 Received: by bwz8 with SMTP id 8so2530133bwz.21 for ; Tue, 22 Feb 2011 11:15:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.70.136 with SMTP id d8mr2851302bkj.96.1298402131403; Tue, 22 Feb 2011 11:15:31 -0800 (PST) Received: by 10.204.14.143 with HTTP; Tue, 22 Feb 2011 11:15:31 -0800 (PST) Date: Tue, 22 Feb 2011 20:15:31 +0100 Message-ID: Subject: [Patch, fortran] PR45743 - [4.6 Regression] gfortran.dg/whole_file_3.f90 ICE: verify_stmts failed: invalid conversion in gimple call with -finline-small-functions From: Paul Richard Thomas To: fortran@gcc.gnu.org, 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 This patch fixes the regression in this PR. Frankly, I think that fixing the warning versus error issue on an obsolescent language feature is a waste of effort. For me it is a WONTFIX. That said, the invalid conversion in gimple is fundamental. It comes about because, in the testcase, the procedure 'r' is passed as an actual argument to 'phload' without otherwise being referenced in the main program. This means that two different declarations are floating around for the actual and formal arguments, which clash during inlining. The most economic fix here is to not try to inline such procedures :-) Undoubtedly, the actual and formal arguments could be connected but this really seems more trouble than it is worth for a procedure without an explicit interface. Bootstrapped and regtested on Ubuntu-10.1/i686 - OK for trunk? Paul 2011-02-22 Paul Thomas PR fortran/45743 * trans-decl.c (gfc_get_extern_function_decl): Don't use the gsymbol backend_decl if the procedure has a formal argument that is a procedure. 2011-02-22 Paul Thomas PR fortran/45743 * gfortran.dg/whole_file_32.f90 : New test. Index: gcc/fortran/trans-decl.c =================================================================== *** gcc/fortran/trans-decl.c (revision 170356) --- gcc/fortran/trans-decl.c (working copy) *************** gfc_get_extern_function_decl (gfc_symbol *** 1495,1500 **** --- 1495,1501 ---- tree name; tree mangled_name; gfc_gsymbol *gsym; + bool proc_formal_arg; if (sym->backend_decl) return sym->backend_decl; *************** gfc_get_extern_function_decl (gfc_symbol *** 1511,1520 **** --- 1512,1538 ---- return the backend_decl. */ gsym = gfc_find_gsymbol (gfc_gsym_root, sym->name); + /* Do not use procedures that have a procedure argument because this + can result in problems of multiple decls during inlining. */ + proc_formal_arg = false; + if (gsym && gsym->ns && gsym->ns->proc_name) + { + gfc_formal_arglist *formal = gsym->ns->proc_name->formal; + for (; formal; formal = formal->next) + { + if (formal->sym && formal->sym->attr.flavor == FL_PROCEDURE) + { + proc_formal_arg = true; + break; + } + } + } + if (gfc_option.flag_whole_file && (!sym->attr.use_assoc || sym->attr.if_source != IFSRC_DECL) && !sym->backend_decl && gsym && gsym->ns + && !proc_formal_arg && ((gsym->type == GSYM_SUBROUTINE) || (gsym->type == GSYM_FUNCTION)) && (gsym->ns->proc_name->backend_decl || !sym->attr.intrinsic)) { Index: gcc/testsuite/gfortran.dg/whole_file_32.f90 =================================================================== *** gcc/testsuite/gfortran.dg/whole_file_32.f90 (revision 0) --- gcc/testsuite/gfortran.dg/whole_file_32.f90 (revision 0) *************** *** 0 **** --- 1,20 ---- + ! { dg-do compile } + ! { dg-options "-O -finline-small-functions" } + ! Tests the fix for PR45743 in which the compilation failed with an ICE + ! internal compiler error: verify_stmts failed. The source is the essential + ! part of whole_file_3.f90. + ! + ! Contributed by Zdenek Sojka + ! + SUBROUTINE PHLOAD (READER,*) + IMPLICIT NONE + EXTERNAL READER + CALL READER (*1) + 1 RETURN 1 + END SUBROUTINE + + program test + EXTERNAL R + CALL PHLOAD (R, *999) ! This one is OK + 999 continue + END program test