From patchwork Wed Oct 20 04:22:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 68389 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 2F93AB70B8 for ; Wed, 20 Oct 2010 15:23:07 +1100 (EST) Received: (qmail 5924 invoked by alias); 20 Oct 2010 04:23:02 -0000 Received: (qmail 5903 invoked by uid 22791); 20 Oct 2010 04:23:01 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from out01.roch.ny.frontiernet.net (HELO out01.roch.ny.frontiernet.net) (66.133.183.226) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Oct 2010 04:22:54 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAAsLvkxA6lwO/2dsb2JhbACDHp47sFqSD4RWdASEVQ Received: from relay03.roch.ny.frontiernet.net ([66.133.182.166]) by out01.roch.ny.frontiernet.net with ESMTP; 20 Oct 2010 04:22:52 +0000 X-Previous-IP: 64.234.92.14 Received: from quava.localdomain (host-64-234-92-14.nctv.com [64.234.92.14]) by relay03.roch.ny.frontiernet.net (Postfix) with ESMTPA id A8AF8101DC; Wed, 20 Oct 2010 04:22:50 +0000 (UTC) Message-ID: <4CBE6EA0.1030709@frontier.com> Date: Tue, 19 Oct 2010 21:22:56 -0700 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 MIME-Version: 1.0 To: Mikael Morin CC: fortran@gcc.gnu.org, gcc patches Subject: Re: [patch, fortran] PR46079 ABI for empty stop statement broken References: <4CBD0631.7090603@frontier.com> <201010192145.29139.mikael.morin@sfr.fr> <4CBE38F2.6060806@frontier.com> In-Reply-To: <4CBE38F2.6060806@frontier.com> 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 On 10/19/2010 05:33 PM, Jerry DeLisle wrote: > On 10/19/2010 12:45 PM, Mikael Morin wrote: --- snip --- >> Let's keep error_stop_string care about strings only. (Please!) >> > Thanks for bringing this up. It was bothering me too I will gladly do this > diffently and will re-submit the patch. Attached is a revised patch. This produces for the following: real, dimension(5,5,5) :: i stop stop 47 stop "string 1" stop size(i) error stop error stop 37 error stop size(i) error stop "string 2" _gfortran_stop_string (0B, 0); _gfortran_stop_numeric_f08 (47); _gfortran_stop_string (&"string 1"[1]{lb: 1 sz: 1}, 8); _gfortran_stop_numeric_f08 (125); _gfortran_error_stop_string (0B, 0); _gfortran_error_stop_numeric (37); _gfortran_error_stop_numeric (125); _gfortran_error_stop_string (&"string 2"[1]{lb: 1 sz: 1}, 8); Regression tested. OK for trunk? Jerry Index: libgfortran/runtime/stop.c =================================================================== --- libgfortran/runtime/stop.c (revision 165674) +++ libgfortran/runtime/stop.c (working copy) @@ -35,6 +35,22 @@ export_proto(stop_numeric); void stop_numeric (GFC_INTEGER_4 code) { + if (code == -1) + code = 0; + else + st_printf ("STOP %d\n", (int)code); + + sys_exit (code); +} +/* A Fortran 2008 numeric STOP statement. */ + +extern void stop_numeric_f08 (GFC_INTEGER_4) + __attribute__ ((noreturn)); +export_proto(stop_numeric_f08); + +void +stop_numeric_f08 (GFC_INTEGER_4 code) +{ st_printf ("STOP %d\n", (int)code); sys_exit (code); } Index: libgfortran/gfortran.map =================================================================== --- libgfortran/gfortran.map (revision 165674) +++ libgfortran/gfortran.map (working copy) @@ -1141,6 +1141,7 @@ GFORTRAN_1.4 { _gfortran_parity_l8; _gfortran_parity_l16; _gfortran_selected_real_kind2008; + _gfortran_stop_numeric_f08; _gfortran_transfer_array_write; _gfortran_transfer_character_write; _gfortran_transfer_character_wide_write; Index: gcc/fortran/trans-stmt.c =================================================================== --- gcc/fortran/trans-stmt.c (revision 165674) +++ gcc/fortran/trans-stmt.c (working copy) @@ -602,25 +602,25 @@ gfc_trans_stop (gfc_code *code, bool error_stop) { tmp = build_int_cst (gfc_int4_type_node, 0); tmp = build_call_expr_loc (input_location, - error_stop ? gfor_fndecl_error_stop_string + error_stop ? gfor_fndecl_error_stop_string : gfor_fndecl_stop_string, - 2, build_int_cst (pchar_type_node, 0), tmp); + 2, build_int_cst (pchar_type_node, 0), tmp); } else if (code->expr1->ts.type == BT_INTEGER) { gfc_conv_expr (&se, code->expr1); tmp = build_call_expr_loc (input_location, - error_stop ? gfor_fndecl_error_stop_numeric - : gfor_fndecl_stop_numeric, 1, + error_stop ? gfor_fndecl_error_stop_numeric + : gfor_fndecl_stop_numeric_f08, 1, fold_convert (gfc_int4_type_node, se.expr)); } else { gfc_conv_expr_reference (&se, code->expr1); tmp = build_call_expr_loc (input_location, - error_stop ? gfor_fndecl_error_stop_string + error_stop ? gfor_fndecl_error_stop_string : gfor_fndecl_stop_string, - 2, se.expr, se.string_length); + 2, se.expr, se.string_length); } gfc_add_expr_to_block (&se.pre, tmp); Index: gcc/fortran/trans.h =================================================================== --- gcc/fortran/trans.h (revision 165674) +++ gcc/fortran/trans.h (working copy) @@ -589,6 +589,7 @@ void gfc_omp_firstprivatize_type_sizes (struct gim extern GTY(()) tree gfor_fndecl_pause_numeric; extern GTY(()) tree gfor_fndecl_pause_string; extern GTY(()) tree gfor_fndecl_stop_numeric; +extern GTY(()) tree gfor_fndecl_stop_numeric_f08; extern GTY(()) tree gfor_fndecl_stop_string; extern GTY(()) tree gfor_fndecl_error_stop_numeric; extern GTY(()) tree gfor_fndecl_error_stop_string; Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 165674) +++ gcc/fortran/trans-decl.c (working copy) @@ -87,6 +87,7 @@ tree gfc_static_ctors; tree gfor_fndecl_pause_numeric; tree gfor_fndecl_pause_string; tree gfor_fndecl_stop_numeric; +tree gfor_fndecl_stop_numeric_f08; tree gfor_fndecl_stop_string; tree gfor_fndecl_error_stop_numeric; tree gfor_fndecl_error_stop_string; @@ -2802,6 +2803,12 @@ gfc_build_builtin_function_decls (void) /* STOP doesn't return. */ TREE_THIS_VOLATILE (gfor_fndecl_stop_numeric) = 1; + gfor_fndecl_stop_numeric_f08 = gfc_build_library_function_decl ( + get_identifier (PREFIX("stop_numeric_f08")), + void_type_node, 1, gfc_int4_type_node); + /* STOP doesn't return. */ + TREE_THIS_VOLATILE (gfor_fndecl_stop_numeric_f08) = 1; + gfor_fndecl_stop_string = gfc_build_library_function_decl_with_spec ( get_identifier (PREFIX("stop_string")), ".R.", void_type_node, 2, pchar_type_node, gfc_int4_type_node);