From patchwork Fri Dec 2 13:25:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 86296 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp312875obb; Fri, 2 Dec 2016 05:25:39 -0800 (PST) X-Received: by 10.98.133.207 with SMTP id m76mr45785249pfk.102.1480685139932; Fri, 02 Dec 2016 05:25:39 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 1si5151334plu.329.2016.12.02.05.25.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 05:25:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443320-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443320-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443320-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=YH+fppohtmkMmP4XCfTI/hENC5XBeGisdbpGP4bcAHVTFM6Kxw hUTUCJzAw/Dg7oaWzQD70qo+jUd+qzK9EeelXXSvtJl0VxSqpWuewmcX4A2jfz2P r3YE6IoszxPgwtNobN5lQWTi36Lz/rsyu5/BWotuypZ8cmFKtE1fkbSmw= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=lI2ES9b0KW8iQgZnKgJjWKKsi/8=; b=DN53XKudQ8Yn7dsLuqQw +ggRmMtbthd8Ytzx79a375ZNtfyV9JbPq3ghQpCXGJgDWD+dB0h9GKY63lbTo0zC wn8Q/16ZpMprM6Dui/sHJ/mNTYJraulnVsShA8OVS2bKX8Q7IQSbxZMF4uLaUp8z beUEXNsXORSxsnc7MUKW4gM= Received: (qmail 73440 invoked by alias); 2 Dec 2016 13:25:26 -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 73370 invoked by uid 89); 2 Dec 2016 13:25:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=U*nathan, 8926, H*F:U*nathan, 892, 6 X-HELO: mail-yb0-f195.google.com Received: from mail-yb0-f195.google.com (HELO mail-yb0-f195.google.com) (209.85.213.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 13:25:15 +0000 Received: by mail-yb0-f195.google.com with SMTP id v78so5080062ybe.0 for ; Fri, 02 Dec 2016 05:25:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:to:cc:from:subject:message-id:date :user-agent:mime-version; bh=SHYjM2s4MIyJfcs2xdwtTyk7N7M6vHNq1tzjcYo36Ys=; b=AzQyO98oRfcPsbvKkjXqc9rfOwkdlsBYfBH6wb7VDHS5IvpVhIE9M50Y17gCrPEH9P x2eD9gsApHEHfL+HTSlcVMNhK0yae+PMuDM6KH3VIDFRWccHi4cCy4K4BRpouKUbIEoI i9gzjTDXZVbDIIae7O0xQAMwo/CZMvmKv/zV/iXvc2zQqTMqLkW8q//tEs0YlkqvMp8D sl2DivhtVRX+cWMoXfcUlVUVVlwl0VVAyVRjZ+T4cZzpjI3SWmYKXaunFLHzcmRVRZcH XuEX/+VT8ARRVnv6eKmmBx5ju/qVjq+mKQ3wB/0+AGgsbxdJaP9vNAZNCx1+ZXMAg57g isKQ== X-Gm-Message-State: AKaTC03KbkMbJIpiloIfIvuFax8h17Lh5lFzwUUmSpKNe263RTcJM/jr27heLk1eJJUgHA== X-Received: by 10.37.170.232 with SMTP id t95mr17311586ybi.166.1480685113788; Fri, 02 Dec 2016 05:25:13 -0800 (PST) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::4dd7]) by smtp.googlemail.com with ESMTPSA id p63sm1863310ywg.17.2016.12.02.05.25.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 05:25:13 -0800 (PST) To: dmalcolm@redhat.com, schwab@linux-m68k.org Cc: GCC Patches From: Nathan Sidwell Subject: [PATCH] fix -fmax-errors & notes, take 2 Message-ID: <95ebd046-fb7c-174d-51fb-3e94b72e27bc@acm.org> Date: Fri, 2 Dec 2016 08:25:11 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Hi, this respin of my notes patch from October (https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00706.html) addresses the fortran problems encountered. I introduced a new function and call it from the fortran error machinery at an appropriate point. ok? nathan -- Nathan Sidwell 2016-12-02 Nathan Sidwell gcc/ * diagnostic.c (diagnostic_check_max_errors): New, broken out of ... (diagnostic_action_after_output): ... here. (diagnostic_report_diagnostic): Call it for non-notes. * diagnostic.h (diagnostic_check_max_errors): Declare. gcc/fortran/ * error.c (gfc_warning_check): Call diagnostic_check_max_errors. (gfc_error_check): Likewise. gcc/testsuite/ * c-c++-common/fmax_errors.c: Check notes after last error are emitted. Index: gcc/diagnostic.c =================================================================== --- gcc/diagnostic.c (revision 243115) +++ gcc/diagnostic.c (working copy) @@ -446,6 +446,29 @@ bt_err_callback (void *data ATTRIBUTE_UN errnum == 0 ? "" : xstrerror (errnum)); } +/* Check if we've met the maximum error limit. */ + +void +diagnostic_check_max_errors (diagnostic_context *context, bool flush) +{ + if (!context->max_errors) + return; + + int count = (diagnostic_kind_count (context, DK_ERROR) + + diagnostic_kind_count (context, DK_SORRY) + + diagnostic_kind_count (context, DK_WERROR)); + + if (count >= (int) context->max_errors) + { + fnotice (stderr, + "compilation terminated due to -fmax-errors=%u.\n", + context->max_errors); + if (flush) + diagnostic_finish (context); + exit (FATAL_EXIT_CODE); + } +} + /* Take any action which is expected to happen after the diagnostic is written out. This function does not always return. */ void @@ -470,18 +493,6 @@ diagnostic_action_after_output (diagnost diagnostic_finish (context); exit (FATAL_EXIT_CODE); } - if (context->max_errors != 0 - && ((unsigned) (diagnostic_kind_count (context, DK_ERROR) - + diagnostic_kind_count (context, DK_SORRY) - + diagnostic_kind_count (context, DK_WERROR)) - >= context->max_errors)) - { - fnotice (stderr, - "compilation terminated due to -fmax-errors=%u.\n", - context->max_errors); - diagnostic_finish (context); - exit (FATAL_EXIT_CODE); - } break; case DK_ICE: @@ -892,6 +901,9 @@ diagnostic_report_diagnostic (diagnostic return false; } + if (diagnostic->kind != DK_NOTE) + diagnostic_check_max_errors (context); + context->lock++; if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT) Index: gcc/diagnostic.h =================================================================== --- gcc/diagnostic.h (revision 243115) +++ gcc/diagnostic.h (working copy) @@ -320,6 +320,7 @@ void default_diagnostic_start_span_fn (d void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *); void diagnostic_set_caret_max_width (diagnostic_context *context, int value); void diagnostic_action_after_output (diagnostic_context *, diagnostic_t); +void diagnostic_check_max_errors (diagnostic_context *, bool flush = false); void diagnostic_file_cache_fini (void); Index: gcc/fortran/error.c =================================================================== --- gcc/fortran/error.c (revision 243115) +++ gcc/fortran/error.c (working copy) @@ -1226,6 +1226,7 @@ gfc_warning_check (void) diagnostic_action_after_output (global_dc, warningcount_buffered ? DK_WARNING : DK_ERROR); + diagnostic_check_max_errors (global_dc, true); } } @@ -1370,6 +1371,7 @@ gfc_error_check (void) gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer)); pp->buffer = tmp_buffer; diagnostic_action_after_output (global_dc, DK_ERROR); + diagnostic_check_max_errors (global_dc, true); return true; } Index: gcc/testsuite/c-c++-common/fmax-errors.c =================================================================== --- gcc/testsuite/c-c++-common/fmax-errors.c (revision 243115) +++ gcc/testsuite/c-c++-common/fmax-errors.c (working copy) @@ -1,11 +1,21 @@ /* PR c/44782 */ /* { dg-do compile } */ -/* { dg-options "-fmax-errors=3" } */ +/* { dg-options "-fmax-errors=3 -Wall" } */ void foo (unsigned int i, unsigned int j) { (i) (); /* { dg-error "" } */ (j) (); /* { dg-error "" } */ - (i+j) (); /* { dg-error "" } */ + + i + j; /* { dg-warning "" } */ + + (k) (); /* { dg-error "" } */ + /* Make sure we see the notes related to the final error we emit. */ + /* { dg-message "identifier" "" { target c } 12 } */ + + /* Warnings after the final error should not appear. */ + i + j; /* no warning. */ + (i*j) (); /* no error here due to -fmax-errors */ + } /* { dg-prune-output "compilation terminated" } */