From patchwork Sat Dec 6 16:33:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 418406 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3BEDF1400E7 for ; Sun, 7 Dec 2014 03:34:03 +1100 (AEDT) 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=RF2OF1oz0FSNrzl26Wb4TAP0uJPVsS7x2C/1PJTt7mXnv8 G3EmlqN9kfgbI8bm7dMPGIllSZzjXmqptNE4ZBuweelplqkcB58PbUy4VH2j8p/a VfDw6DYOT5N5CmX8HNDMML1Q7j+Tp/GPh2OWoBFmKIBF3R54eS8a9M+rwfTig= 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=pVLqcAkBNNOtihXivhqtO0sFX6k=; b=CQeNDLkyaHiMDGk53rFQ 7Ls+SeGYErsVpKheuhG+jJWs1uwPmrhLxWcu+vwax2AjX+R8lT6qI7r/sTb4aorZ mvTnU1+xUquViCRhLA7bIGb/0Pyz//9ghhtVmnHpcF2rl9qLlyZEONEEBTMR7iXU PQiVheceypAs/z0seR9URW0= Received: (qmail 25060 invoked by alias); 6 Dec 2014 16:33:56 -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 25038 invoked by uid 89); 6 Dec 2014 16:33:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx02.qsc.de Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 06 Dec 2014 16:33:53 +0000 Received: from tux.net-b.de (port-92-194-114-130.dynamic.qsc.de [92.194.114.130]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPSA id 88A97252C9; Sat, 6 Dec 2014 17:33:49 +0100 (CET) Message-ID: <54832FEC.20005@net-b.de> Date: Sat, 06 Dec 2014 17:33:48 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: gcc-patches , gfortran , =?UTF-8?B?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= Subject: [Patch, Fortran, committed] bool cleanup in error.c This patch does a cleanup in error.c; it changes come "int" values to "bool" – based on Manuel's RFC patch – and it consolidates two buffers flags. Committed as Rev. 218449 as obvious. Tobias Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 218448) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,3 +1,20 @@ +2014-12-06 Tobias Burnus + Manuel López-Ibáñez + + * error.c (gfc_buffer_error, gfc_error_flag_test): Use bool not int. + (buffer_flag): Remove static variable. + (buffered_p): Add static variable. + (gfc_error_init_1): Call gfc_buffer_error. + (gfc_warning_1, gfc_warning, gfc_warning_now_1, gfc_error, + gfc_error_now_1): Update for static variable change. + * gfortran.h (gfc_buffer_error, gfc_error_flag_test): Update + prototype. + * parse.c (use_modules, decode_specification_statement, + next_fixed, next_statement, match_deferred_characteristics): + Update calls. + * decl.c (gfc_match_data_decl): Ditto. + * match.c (gfc_match_name): Ditto. + 2014-12-05 Andre Vehreschild PR fortran/60414 Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (Revision 218448) +++ gcc/fortran/decl.c (Arbeitskopie) @@ -4397,7 +4397,7 @@ ok: break; } - if (gfc_error_flag_test () == 0) + if (!gfc_error_flag_test ()) gfc_error ("Syntax error in data declaration at %C"); m = MATCH_ERROR; Index: gcc/fortran/error.c =================================================================== --- gcc/fortran/error.c (Revision 218448) +++ gcc/fortran/error.c (Arbeitskopie) @@ -46,10 +46,15 @@ static int suppress_errors = 0; static bool warnings_not_errors = false; -static int terminal_width, buffer_flag, errors, warnings; +static int terminal_width, errors, warnings; static gfc_error_buf error_buffer, warning_buffer, *cur_error_buffer; +/* True if the error/warnings should be buffered. */ +static bool buffered_p; + +/* These are always buffered buffers (.flush_p == false) to be used by + the pretty-printer. */ static output_buffer pp_warning_buffer; static int warningcount_buffered, werrorcount_buffered; @@ -116,7 +121,7 @@ gfc_error_init_1 (void) terminal_width = get_terminal_width (); errors = 0; warnings = 0; - buffer_flag = 0; + gfc_buffer_error (false); } @@ -123,20 +128,20 @@ gfc_error_init_1 (void) /* Set the flag for buffering errors or not. */ void -gfc_buffer_error (int flag) +gfc_buffer_error (bool flag) { - buffer_flag = flag; + buffered_p = flag; pp_warning_buffer.flush_p = !flag; } /* Add a single character to the error buffer or output depending on - buffer_flag. */ + buffered_p. */ static void error_char (char c) { - if (buffer_flag) + if (buffered_p) { if (cur_error_buffer->index >= cur_error_buffer->allocated) { @@ -844,7 +849,7 @@ gfc_warning_1 (const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { warnings++; if (warnings_are_errors) @@ -869,7 +874,6 @@ gfc_warning (int opt, const char *gmsgid, va_list bool fatal_errors = global_dc->fatal_errors; pretty_printer *pp = global_dc->printer; output_buffer *tmp_buffer = pp->buffer; - bool buffered_p = !pp_warning_buffer.flush_p; gfc_clear_pp_buffer (&pp_warning_buffer); @@ -1021,7 +1025,7 @@ gfc_notify_std (int std, const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { if (warning && !warnings_are_errors) warnings++; @@ -1042,13 +1046,13 @@ void gfc_warning_now_1 (const char *gmsgid, ...) { va_list argp; - int i; + bool buffered_p_saved; if (inhibit_warnings) return; - i = buffer_flag; - buffer_flag = 0; + buffered_p_saved = buffered_p; + buffered_p = false; warnings++; va_start (argp, gmsgid); @@ -1060,7 +1064,7 @@ gfc_warning_now_1 (const char *gmsgid, ...) if (warnings_are_errors) gfc_increment_error_count(); - buffer_flag = i; + buffered_p = buffered_p_saved; } /* Called from output_format -- during diagnostic message processing @@ -1336,7 +1340,7 @@ gfc_error (const char *gmsgid, ...) error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) gfc_increment_error_count(); return; @@ -1356,7 +1360,7 @@ warning: error_char ('\0'); - if (buffer_flag == 0) + if (!buffered_p) { warnings++; if (warnings_are_errors) @@ -1373,14 +1377,14 @@ void gfc_error_now_1 (const char *gmsgid, ...) { va_list argp; - int i; + bool buffered_p_saved; error_buffer.flag = 1; error_buffer.index = 0; cur_error_buffer = &error_buffer; - i = buffer_flag; - buffer_flag = 0; + buffered_p_saved = buffered_p; + buffered_p = false; va_start (argp, gmsgid); error_print (_("Error:"), _(gmsgid), argp); @@ -1390,7 +1394,7 @@ gfc_error_now_1 (const char *gmsgid, ...) gfc_increment_error_count(); - buffer_flag = i; + buffered_p = buffered_p_saved; if (flag_fatal_errors) exit (FATAL_EXIT_CODE); @@ -1426,7 +1430,7 @@ gfc_clear_error (void) /* Tests the state of error_flag. */ -int +bool gfc_error_flag_test (void) { return error_buffer.flag; Index: gcc/fortran/gfortran.h =================================================================== --- gcc/fortran/gfortran.h (Revision 218448) +++ gcc/fortran/gfortran.h (Arbeitskopie) @@ -2668,7 +2668,7 @@ typedef struct gfc_error_buf void gfc_error_init_1 (void); void gfc_diagnostics_init (void); void gfc_diagnostics_finish (void); -void gfc_buffer_error (int); +void gfc_buffer_error (bool); const char *gfc_print_wide_char (gfc_char_t); @@ -2689,7 +2689,7 @@ void gfc_fatal_error (const char *, ...) ATTRIBUTE void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2); void gfc_clear_error (void); int gfc_error_check (void); -int gfc_error_flag_test (void); +bool gfc_error_flag_test (void); notification gfc_notification_std (int); bool gfc_notify_std (int, const char *, ...) ATTRIBUTE_GCC_GFC(2,3); Index: gcc/fortran/match.c =================================================================== --- gcc/fortran/match.c (Revision 218448) +++ gcc/fortran/match.c (Arbeitskopie) @@ -532,7 +532,7 @@ gfc_match_name (char *buffer) c = gfc_next_ascii_char (); if (!(ISALPHA (c) || (c == '_' && gfc_option.flag_allow_leading_underscore))) { - if (gfc_error_flag_test () == 0 && c != '(') + if (!gfc_error_flag_test () && c != '(') gfc_error ("Invalid character in name at %C"); gfc_current_locus = old_loc; return MATCH_NO; Index: gcc/fortran/parse.c =================================================================== --- gcc/fortran/parse.c (Revision 218448) +++ gcc/fortran/parse.c (Arbeitskopie) @@ -110,9 +110,9 @@ use_modules (void) gfc_error_buf old_error; gfc_push_error (&old_error); - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_use_modules (); - gfc_buffer_error (1); + gfc_buffer_error (true); gfc_pop_error (&old_error); gfc_commit_symbols (); gfc_warning_check (); @@ -279,7 +279,7 @@ decode_specification_statement (void) end_of_block: gfc_clear_error (); - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_current_locus = old_locus; return ST_GET_FCN_CHARACTERISTICS; @@ -994,7 +994,7 @@ next_fixed (void) if (c != ' ' && c != '0') { - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Bad continuation line at %C"); return ST_NONE; } @@ -1008,7 +1008,7 @@ next_fixed (void) here so don't bother checking for them. */ default: - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Non-numeric character in statement label at %C"); return ST_NONE; } @@ -1035,7 +1035,7 @@ next_fixed (void) if (c != ' ' && c != '0') { - gfc_buffer_error (0); + gfc_buffer_error (false); gfc_error ("Bad continuation line at %C"); return ST_NONE; } @@ -1100,7 +1100,7 @@ next_statement (void) for (;;) { gfc_statement_label = NULL; - gfc_buffer_error (1); + gfc_buffer_error (true); if (gfc_at_eol ()) gfc_advance_line (); @@ -1124,7 +1124,7 @@ next_statement (void) break; } - gfc_buffer_error (0); + gfc_buffer_error (false); if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL) { @@ -2815,9 +2815,9 @@ match_deferred_characteristics (gfc_typespec * ts) gfc_current_locus = gfc_current_block ()->declared_at; gfc_clear_error (); - gfc_buffer_error (1); + gfc_buffer_error (true); m = gfc_match_prefix (ts); - gfc_buffer_error (0); + gfc_buffer_error (false); if (ts->type == BT_DERIVED) {