From patchwork Thu Jun 27 05:27:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 1123110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503833-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=temperror (0-bit key) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kO88WmKD"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A4CBLtSa"; dkim-atps=neutral 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 45Z7j129NRz9s4Y for ; Thu, 27 Jun 2019 15:28:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=WZ3DCpyXY8FBV7qg r0PllbC4ICTIu4DqfzS/5rvmGExFAHFej5GVA8YDRbJePUUmQcjRSpvrxMEsJkNZ Ip7VVDYmoQ79wij0IvCxZJnpQLw9IhhPnsKqvpaDHPUtb8jC5iRWz0RMn3k2sGOT ouXC/urgO1KQVLJ/+dDjSqu+AYo= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=kfFfsC+LrzmjilxEZXA3y2 LoMsM=; b=kO88WmKDUFScOf01rqVp9+Nqg55R8nBDp7NoQf7Fip604XcfqMIrrE TrHHCr6JnzemF0L59Dtna5LhMEUAAtTdSpY3ag4GXMi0GhTr7qanVy+VbwAa50dI EL8TrL6Ae7+AjSaMEXbPEx5hOeFjmE5YQ3qeydi/d2VdemhhEGYMY= Received: (qmail 36717 invoked by alias); 27 Jun 2019 05:28:04 -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 36704 invoked by uid 89); 27 Jun 2019 05:28:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=BAYES_20, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=warning_at, Wno-error, sk:ignored, sk:somefu X-HELO: mail-io1-f66.google.com Received: from mail-io1-f66.google.com (HELO mail-io1-f66.google.com) (209.85.166.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jun 2019 05:28:03 +0000 Received: by mail-io1-f66.google.com with SMTP id i10so1931473iol.13; Wed, 26 Jun 2019 22:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=8DPFkJAcM9Y/ih6NalFZDQY1mKI2oYX0GDV37kb+aEA=; b=A4CBLtSaIvsXCHu0F7fy73Y7vp3UnGk634PADlGDn4SW1hLUSnBXKag5LPxyYAE3vO crw2N0rNNRd1625Buzixmx3/5QIHObzMbsKny2jGiND3lJrmvQGs9vCHgZt3Jae3Q2Kb z7tAgBh+4vDaTeEW4NtnKZY+aK597/BKDVh9lg8HbJyAKgYMCYR+kO+gubMS+scq0AsM rKbnYwcGoFVWaA4gJMc+s+lW6fS8eZ0n59JFKprcbQ9Ojd/sjRuNKRC6i3jWAUwdndb7 FBoLX7mMs6QjCYCoZQt+jhJ5/o9XjPWfyaXU0xfdZl/5jaB8tictNVkJie7wVIg5X/b0 b4CA== Received: from xavier.hsd1.ut.comcast.net ([2601:681:4100:375e:f2d5:bfff:fecd:8741]) by smtp.gmail.com with ESMTPSA id p3sm866997iog.70.2019.06.26.22.27.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 22:28:00 -0700 (PDT) From: Alex Henrie To: gcc-patches@gcc.gnu.org, manu@gcc.gnu.org, mliska@suse.cz, joseph@codesourcery.com, msebor@gmail.com, law@redhat.com Subject: [PATCH v3 1/2] PR c/65403 - Ignore -Wno-error= Date: Wed, 26 Jun 2019 23:27:02 -0600 Message-Id: <20190627052703.10080-1-alexhenrie24@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes From: Manuel López-Ibáñez * opts-common.c (ignored_wnoerror_options): New global variable. * opts-global.c (print_ignored_options): Ignore -Wno-error= except if there are other diagnostics. * opts.c (enable_warning_as_error): Record ignored -Wno-error options. * opts.h (ignored_wnoerror_options): Declare. * gcc.dg/Werror-13.c: Don't expect hints for -Wno-error=. --- gcc/opts-common.c | 2 ++ gcc/opts-global.c | 10 +++++++--- gcc/opts.c | 21 +++++++++++++-------- gcc/opts.h | 2 ++ gcc/testsuite/gcc.dg/Werror-13.c | 2 +- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 660dfe63858..8ceb8461f97 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -26,6 +26,8 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "spellcheck.h" +vec ignored_wnoerror_options; + static void prune_options (struct cl_decoded_option **, unsigned int *); /* An option that is undocumented, that takes a joined argument, and diff --git a/gcc/opts-global.c b/gcc/opts-global.c index bf4db775928..1d5d4e69dfc 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -132,12 +132,16 @@ print_ignored_options (void) { while (!ignored_options.is_empty ()) { - const char *opt; - - opt = ignored_options.pop (); + const char * opt = ignored_options.pop (); warning_at (UNKNOWN_LOCATION, 0, "unrecognized command-line option %qs", opt); } + while (!ignored_wnoerror_options.is_empty ()) + { + const char * opt = ignored_wnoerror_options.pop (); + warning_at (UNKNOWN_LOCATION, 0, + "%<-Wno-error=%s%>: no option %<-W%s%>", opt, opt); + } } /* Handle an unknown option DECODED, returning true if an error should diff --git a/gcc/opts.c b/gcc/opts.c index b38bfb15a56..f31b6aa877e 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -3095,15 +3095,20 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask, option_index = find_opt (new_option, lang_mask); if (option_index == OPT_SPECIAL_unknown) { - option_proposer op; - const char *hint = op.suggest_option (new_option); - if (hint) - error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;" - " did you mean %<-%s%>?", value ? "" : "no-", - arg, new_option, hint); + if (value) + { + option_proposer op; + const char *hint = op.suggest_option (new_option); + if (hint) + error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>;" + " did you mean %<-%s%>?", value ? "" : "no-", + arg, new_option, hint); + else + error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>", + value ? "" : "no-", arg, new_option); + } else - error_at (loc, "%<-W%serror=%s%>: no option %<-%s%>", - value ? "" : "no-", arg, new_option); + ignored_wnoerror_options.safe_push (arg); } else if (!(cl_options[option_index].flags & CL_WARNING)) error_at (loc, "%<-Werror=%s%>: %<-%s%> is not an option that " diff --git a/gcc/opts.h b/gcc/opts.h index e5723a946f7..f553e8d00f0 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -460,4 +460,6 @@ extern bool parse_and_check_align_values (const char *flag, bool report_error, location_t loc); +extern vec ignored_wnoerror_options; + #endif diff --git a/gcc/testsuite/gcc.dg/Werror-13.c b/gcc/testsuite/gcc.dg/Werror-13.c index 3a02b7ea2b5..7c2bf6836ed 100644 --- a/gcc/testsuite/gcc.dg/Werror-13.c +++ b/gcc/testsuite/gcc.dg/Werror-13.c @@ -5,6 +5,6 @@ /* { dg-error "'-Werror' is not an option that controls warnings" "" { target *-*-* } 0 } */ /* { dg-error "'-Wfatal-errors' is not an option that controls warnings" "" { target *-*-* } 0 } */ /* { dg-error "'-Werror=vla2': no option '-Wvla2'; did you mean '-Wvla." "" { target *-*-* } 0 } */ -/* { dg-error "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'; did you mean '-Wmisleading-indentation'" "" { target *-*-* } 0 } */ +/* { dg-warning "'-Wno-error=misleading-indentation2': no option '-Wmisleading-indentation2'" "" { target *-*-* } 0 } */ int i; From patchwork Thu Jun 27 05:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 1123111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503834-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UAgNpNcs"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tCom0+GH"; dkim-atps=neutral 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 45Z7j31gRpz9sLt for ; Thu, 27 Jun 2019 15:28:23 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; q=dns; s=default; b=rzE lPkZY3HKhvCthjOjKkQ44IcEFhZp79YHQGo/sGaieG5t6PD4IZbqP8KYVlS+wkZ6 xfmRqJf+a/R6n0HWaUqHud8yF3Dc9Zg6wKNe/WZR9Ih2/Jpiti3dh/qnXV26d3Ia JzHxLPmElzJyDGViGqMyExAVsjG3/G6SBhPtzGZ4= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=default; bh=UT5t6I49P WDctEjo8skZdKiBRKs=; b=UAgNpNcs2s11AUuLZVgJXqlRWF8EXPNRpy9tlmTQX Af0Y1SyvU+tcPTS0s4i4zHeEe7nKCorEXlMuCGqGDYiPOvn1stZ9ke+i0NU9F5RS kJVAsfYuQAY0Whw0L+Qz3WHoowCW6QWKWiLPZRaZX6sq2CHwO6rMsVmLAbIGdqpt YU= Received: (qmail 36936 invoked by alias); 27 Jun 2019 05:28: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 36879 invoked by uid 89); 27 Jun 2019 05:28:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1690, wnoerror, Wnoerror, sk:somefu X-HELO: mail-io1-f41.google.com Received: from mail-io1-f41.google.com (HELO mail-io1-f41.google.com) (209.85.166.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Jun 2019 05:28:04 +0000 Received: by mail-io1-f41.google.com with SMTP id k20so1966386ios.10; Wed, 26 Jun 2019 22:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tDuxM+30mZWYIib7tn9KSVX6tUZabFCN2Bzq9U+Cmxw=; b=tCom0+GHST85GmZW1bG1uwA67Dsj4aGV6VH0uLaUT++kvpJE0AFjwVaP7SyxPHbp0D 2NUQXDw31rjvcEBbnUjp9aGpeDrhQAJdAdC6ka+UPCA9nenFwkxkccBSxc9WFh3peN8I DTtX5735amcf2SnNk7Pgd5nNG43Dy3cqb6ae+fxGN9L3P784hXHXKrf/5527KdE+k862 gGuQmqgxAbL/qyqYm+cCZrNfGC4GNtQvlETIfU5kC2l1r+BzLavYo28CsE9VNfJT6leP gLgY3vZVcklzXLXcP5+Bst7pBDApOrvfLLGeLrfnv4GGN11Cw+xB/C0wzgNURwMB7s5n ziug== Received: from xavier.hsd1.ut.comcast.net ([2601:681:4100:375e:f2d5:bfff:fecd:8741]) by smtp.gmail.com with ESMTPSA id p3sm866997iog.70.2019.06.26.22.28.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 22:28:01 -0700 (PDT) From: Alex Henrie To: gcc-patches@gcc.gnu.org, manu@gcc.gnu.org, mliska@suse.cz, joseph@codesourcery.com, msebor@gmail.com, law@redhat.com Cc: Alex Henrie Subject: [PATCH v3 2/2] PR c/65403 - Add tests for -Wno-error= Date: Wed, 26 Jun 2019 23:27:03 -0600 Message-Id: <20190627052703.10080-2-alexhenrie24@gmail.com> In-Reply-To: <20190627052703.10080-1-alexhenrie24@gmail.com> References: <20190627052703.10080-1-alexhenrie24@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes * c-c++-common/pr65403-1.c: New test. * c-c++-common/pr65403-2.c: New test. --- gcc/testsuite/c-c++-common/pr65403-1.c | 10 ++++++++++ gcc/testsuite/c-c++-common/pr65403-2.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/pr65403-1.c create mode 100644 gcc/testsuite/c-c++-common/pr65403-2.c diff --git a/gcc/testsuite/c-c++-common/pr65403-1.c b/gcc/testsuite/c-c++-common/pr65403-1.c new file mode 100644 index 00000000000..fbe004a1f78 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr65403-1.c @@ -0,0 +1,10 @@ +/* PR c/65403 */ +/* Test an unrecognized -Wno-error option in the absence of any other + diagnostics. The -Wno-error option should be ignored. */ + +/* { dg-options "-Werror -Wno-error=some-future-warning" } */ + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/gcc/testsuite/c-c++-common/pr65403-2.c b/gcc/testsuite/c-c++-common/pr65403-2.c new file mode 100644 index 00000000000..8b5faa7270e --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr65403-2.c @@ -0,0 +1,15 @@ +/* PR c/65403 */ +/* Test a warning, treated as an error, that some future -Wno-error option + might downgrade back to a warning. The -Wno-error option should produce a + warning in this case. */ + +/* { dg-options "-Wunused-variable -Werror -Wno-error=some-future-warning" } */ + +int main(int argc, char **argv) +{ + int foo; /* { dg-error "unused variable 'foo'" } */ + return 0; +} + +/* { dg-error "no option '-Wsome-future-warning'" "" { target *-*-* } 0 } */ +/* { dg-message "all warnings being treated as errors" "" { target *-*-* } 0 } */