From patchwork Thu Nov 27 22:58:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 415728 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 4C5D51401AD for ; Fri, 28 Nov 2014 09:59:14 +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:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=fyfuBKg4s2Ft+ELMc d/LVtef8+NUngbRv9iO75Aq0UZ2ljAQ+bTfFxfpe+vHxz8tw+sFsG4gaqN28OLWW RC79htGEmdBEH5YZxmRhFdfMyfq2rrYht0Y185wk1AbFyf6Hd0ne5lHNiJ+2U2X7 i3Pn9DhKen3eo7bVLwmwanZ5+c= 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:cc:subject:references :in-reply-to:content-type; s=default; bh=x1V1B5yxRR+uGdlflS8wMY0 T0nU=; b=WShpCMSYwvnOW+w4cdwkrJ1mqOkiwfOt/4HyPIuAPFL3AIzZ+vEImti nqNH/Kb8YVJ/qszYvdDzjFRo6388Mc2G3jpr6nXyWtYbFcFMOaaT65TJrkLynxcK 7rvIXndBN+dS6GFDkTRr84uFQLR94SA++UvOYBHBBkhktFkY4mQY= Received: (qmail 21297 invoked by alias); 27 Nov 2014 22:59:06 -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 21279 invoked by uid 89); 27 Nov 2014 22:59:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, 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; Thu, 27 Nov 2014 22:59:03 +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 A42A2276A6; Thu, 27 Nov 2014 23:58:59 +0100 (CET) Message-ID: <5477ACB3.2000409@net-b.de> Date: Thu, 27 Nov 2014 23:58:59 +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: =?windows-1252?Q?Manuel_L=F3pez-Ib=E1=F1ez?= CC: FX , gcc-patches , gfortran , Dodji Seketeli Subject: Re: [RFC diagnostics/fortran] Move gfc_warning (buffered) to the common diagnostics machinery References: <54777B77.3050002@net-b.de> In-Reply-To: Manuel López-Ibáñez wrote: > Oh, I didn't notice that the _now versions override the buffered > messages. Where do you see that? I think I messed up a bit - they do not seem to get cleared. I was reading gfc_error_now_1, which has: error_buffer.flag = 1; error_buffer.index = 0; cur_error_buffer = &error_buffer; and I misread the "error_buffer.index = 0" as resetting the output. However, this "index = 0" is completely unused as one has unbuffered output and it only applies to the next error. Actually, I wonder whether that can lead to printing an error message multiple times. Assume a buffered message, that's printed with gfc_error_check(), which sets flags = 0, but the buffer->message still contains the message. gfc_error_now_1 sets the flag to 1; it doesn't touch the buffer itself as it directly outputs the message. If one now calls gfc_error_check(), it outputs the previous buffer again. I wonder whether that's sometimes happens. I do recall seeing the same message multiple times without understanding why. Thus, I withdraw the comment. And regarding error push/pop: I also missed that point. >> Well, for nearly every Fortran program, at least for one line multiple >> attempts have to be done by the parser. Thus, if you set a break point in >> gfc_error, you will see "syntax error" messages which never make it to the >> screen. As the test suite checks for excess errors, nearly every test-suite >> file tests this. > Sure, but I would like to test specifically triggering and discarding > the gfc_warning that I converted (or another single one that you > suggest), if this were possible. Hmm, theoretically, it would be possible. However, my feeling is that there is no such case. What would be needed is something which is ambiguous, the compiler assumes first the wrong kind of statement, fails, and retries is with a different kind of statement. That's simple. However, either one has already aborted (gfc_error or NO_MATCH) *before* reaching a gfc_warning – or the code is valid and, hence, the buffered warning is printed. Hence, sorry, I cannot deliver for gfc_warning. For error, I'd could create one. >> Some of those can probably be simply converted, others either need to >> remain, or one has to setup a proper location (currently, using >> gfc_warning_now would ICE), or one creates a work around and constructs >> manually the error string (at least for the fprintf cases). > Why does it ICE? At worst it should give a wrong location, but the > computation of the offset is fairly similar to what Fortran already > does. Could you give me a patch+testcase that ICEs? Maybe it has been fixed by your latest patch, which added %L, but using printf '\tend' > test.f90; gfortran -Wtabs test.f90 used to ICE for me. However, it no longer ICEs. Thus, the following patch could be committed: at %C"); I also confirm that the "!$OMP" warning now works correctly. However, the change - gfc_warning_now_1 ("Line truncated at %L", &gfc_current_locus); + gfc_warning_now ("Line truncated at %L", &gfc_current_locus); still triggers an ICE with "gfortran -Wall test.f90" and with "test.f" (two locations in scanner.c; see attached test cases and attache patch). The backtrace for test.f90 is: Aborted 0xb6c38f crash_signal ../../gcc/toplev.c:359 0x1244620 linemap_position_for_loc_and_offset(line_maps*, unsigned int, unsigned int) ../../libcpp/line-map.c:648 0x63247a gfc_format_decoder ../../gcc/fortran/error.c:991 0x1231e8c pp_format(pretty_printer*, text_info*) ../../gcc/pretty-print.c:616 0x122f6ec diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../gcc/diagnostic.c:820 0x63380b gfc_warning_now(char const*, ...) ../../gcc/fortran/error.c:1133 0x69aca9 gfc_next_char_literal(gfc_instring) ../../gcc/fortran/scanner.c:1059 Besides those, there is additionally: gfc_warning_now_1 ("%s:%d: Illegal preprocessor directive", which I haven't tested. Tobias diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index 884fe70..5b42777 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -777,6 +777,6 @@ skip_free_comments (void) else - gfc_warning_now_1 ("!$OMP at %C starts a commented " - "line as it neither is followed " - "by a space nor is a " - "continuation line"); + gfc_warning_now ("!$OMP at %C starts a commented " + "line as it neither is followed " + "by a space nor is a " + "continuation line"); } @@ -1058,3 +1058,3 @@ restart: gfc_current_locus.nextc = gfc_current_locus.lb->line + maxlen; - gfc_warning_now_1 ("Line truncated at %L", &gfc_current_locus); + gfc_warning_now ("Line truncated at %L", &gfc_current_locus); gfc_current_locus.nextc = current_nextc; @@ -1196,3 +1196,3 @@ restart: gfc_current_locus.lb->truncated = 0; - gfc_warning_now_1 ("Line truncated at %L", &gfc_current_locus); + gfc_warning_now ("Line truncated at %L", &gfc_current_locus); } @@ -1390,3 +1390,3 @@ gfc_gobble_whitespace (void) linenum = cur_linenum; - gfc_warning_now_1 ("Nonconforming tab character at %C"); + gfc_warning_now (OPT_Wtabs, "Nonconforming tab character at %C"); }