From patchwork Sat Nov 29 12:11:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 415990 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 8932514012F for ; Sat, 29 Nov 2014 23:12:02 +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=jW5FXwZ7zrehuYK9xj5pnevxF44SeulZBUZcFxQM+IKeN4 BbngxKIvZyzeSWfGY+ZzSahlhMojx3lJDNNXSp+M04w9YivJWFYPzVAUXsW0Df2k MsYDxTNC3wWNoCi5pZwbtnNpwWJqvnr7yJMwiMbLPK5k7GpqLNosX57Sz+iTM= 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=Lr3iGfa2HJLGR43re6E4nRZPw7c=; b=jwEbL7/Gxpt3Z919hVXy /DwKK6Xw+Gh/rj0KY9DiZKEW9KlkGxk3KjqDhWuRfu/fnJ+rLTOSrqIIVd7od6m0 Knl5Xhobhz79HvY2AgstsTYjIv2ranGwK/7iZDBVwabJwZ4NYFRS4Gp5U8m+xAXj Vz5M9XB45enMKzdKOI+zUrc= Received: (qmail 20407 invoked by alias); 29 Nov 2014 12:11:48 -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 20388 invoked by uid 89); 29 Nov 2014 12:11:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx01.qsc.de Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sat, 29 Nov 2014 12:11:46 +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 mx01.qsc.de (Postfix) with ESMTPSA id 29A7C3CE70; Sat, 29 Nov 2014 13:11:41 +0100 (CET) Message-ID: <5479B7FD.20805@net-b.de> Date: Sat, 29 Nov 2014 13:11:41 +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: =?UTF-8?B?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= , FX , gcc-patches , gfortran Subject: [Patch, Fortran, RFC] Use gfc_warning_now for gfc_warning Hi all, this patch uses the unbuffered gfc_warning_now code for gfc_warning, which might be buffered. Looking at the code, I fail to construct a code where buffering would be done - and the buffer be dropped in case of warnings. I used defines to make it simpler to re-instate buffereing in case it will be needed at some point. Note: For gfc_errors, dropping the buffer *does* happen. I have also not completely investigated gfc_notify_std for the warning case, but the _DEL and _OBS seem to be only issued after nonambiguous code. I wondered whether "goto var = 1" would trigger it, but seemingly "gotovar = 1" is matched before "goto var" as the warning is not triggered. Regtesting didn't show any failures. Is the patch OK for the trunk? Do you have comments, concerns or similar? Tobias PS: After that patch – or, alternatively, Manuel's buffered warning patch - is in, I will add OPT_W* to the gfc_warning. We also have to think about notify_std. diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 1864145..6c6b7d1 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -956,10 +956,10 @@ gfc_check_argument_var_dependency (gfc_expr *var, sym_intent intent, If a dependency is found in the case elemental == ELEM_CHECK_VARIABLE, we will generate a temporary, so we don't need to bother the user. */ - gfc_warning ("INTENT(%s) actual argument at %L might " - "interfere with actual argument at %L.", - intent == INTENT_OUT ? "OUT" : "INOUT", - &var->where, &expr->where); + gfc_warning_1 ("INTENT(%s) actual argument at %L might " + "interfere with actual argument at %L.", + intent == INTENT_OUT ? "OUT" : "INOUT", + &var->where, &expr->where); } return 0; } diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c index 00e9228..a40bdde 100644 --- a/gcc/fortran/error.c +++ b/gcc/fortran/error.c @@ -804,35 +804,6 @@ gfc_increment_error_count (void) } -/* Issue a warning. */ - -void -gfc_warning (const char *gmsgid, ...) -{ - va_list argp; - - if (inhibit_warnings) - return; - - warning_buffer.flag = 1; - warning_buffer.index = 0; - cur_error_buffer = &warning_buffer; - - va_start (argp, gmsgid); - error_print (_("Warning:"), _(gmsgid), argp); - va_end (argp); - - error_char ('\0'); - - if (buffer_flag == 0) - { - warnings++; - if (warnings_are_errors) - gfc_increment_error_count(); - } -} - - /* Whether, for a feature included in a given standard set (GFC_STD_*), we should issue an error or a warning, or be quiet. */ diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 095d526..bb7ed61 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2690,7 +2690,10 @@ void gfc_buffer_error (int); const char *gfc_print_wide_char (gfc_char_t); -void gfc_warning (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); +/* Contrary to gfc_warning_now, gfc_warning could be buffered. However, it + turned out that the buffer is never dropped but always printed. */ +#define gfc_warning_1 gfc_warning_now_1 +#define gfc_warning gfc_warning_now void gfc_warning_now_1 (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); bool gfc_warning_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); bool gfc_warning_now (int opt, const char *, ...) ATTRIBUTE_GCC_GFC(2,3); diff --git a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f index 49bf112..510f93e 100644 --- a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f +++ b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f @@ -18,7 +18,7 @@ end do call foo j bar ! gfc_warning: - r2(4) = 0 ! { dg-warning "is out of bounds" } + r2(4) = 0 ! { dg-error "is out of bounds" } goto 3 45 end diff --git a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90 b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90 index 8ce4699..efb4508 100644 --- a/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90 +++ b/gcc/testsuite/gfortran.dg/warnings_are_errors_1.f90 @@ -17,7 +17,7 @@ implicit none ! gfc_warning: -1234 complex :: cplx ! { dg-warning "defined but cannot be used" } +1234 complex :: cplx ! { dg-error "defined but cannot be used" } cplx = 20. ! gfc_warning_now: