public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: "Bernd Schmidt" <bschmidt@redhat.com>,
	"Manuel López-Ibáñez" <lopezibanez@gmail.com>,
	"Joseph S. Myers" <joseph@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix -Werror= handling with aliases (PR c/68833)
Date: Fri, 11 Dec 2015 20:18:00 -0000	[thread overview]
Message-ID: <20151211201807.GK5675@tucnak.redhat.com> (raw)
In-Reply-To: <5666C564.7080506@redhat.com>

Hi!

On Tue, Dec 08, 2015 at 12:56:20PM +0100, Bernd Schmidt wrote:
> On 12/07/2015 11:41 PM, Jakub Jelinek wrote:
> >On Mon, Dec 07, 2015 at 04:11:48PM +0100, Bernd Schmidt wrote:
> >>Let's document arguments; for the ones identical to read_cmdline_option an
> >>explicit pointer there is sufficient, but errors is new.
> >
> >>This also needs an update to the function comment.
> >>
> >>Other than that I'm ok with this. This area could probably be restructured a
> >>bit but for now I think this is good enough.
> >
> >So like this?  Bootstrapped/regtested on x86_64-linux and i686-linux.
> 
> Yes, thanks.

Unfortunately, my patch broke some cases with warning aliases that happened
to work (by accident) and left some other warning alias cases broken.

This patch attempts to fix that (and add Warning keyword to two warning
aliases that didn't have it), so that -Werror= works even for them again.
As we do nothing beyond cancelling -Werror for -Wno-error=, there is no need
to deal with neg_alias_arg, just alias_arg is enough.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-12-11  Jakub Jelinek  <jakub@redhat.com>

	PR c/68833
	* common.opt (Wmissing-noreturn): Add Warning option.
	* opts-common.c (control_warning_option): If opt is
	alias_target with alias_arg, set arg to it.

	* c.opt (Wmissing-format-attribute, Wnormalized): Add Warning option.

	* c-c++-common/pr68833-1.c: New test.
	* c-c++-common/pr68833-2.c: New test.

--- gcc/common.opt.jj	2015-12-08 14:25:19.000000000 +0100
+++ gcc/common.opt	2015-12-11 16:29:30.257521500 +0100
@@ -612,7 +612,7 @@ Common Var(warn_unsafe_loop_optimization
 Warn if the loop cannot be optimized due to nontrivial assumptions.
 
 Wmissing-noreturn
-Common Alias(Wsuggest-attribute=noreturn)
+Common Warning Alias(Wsuggest-attribute=noreturn)
 
 Wodr
 Common Var(warn_odr_violations) Init(1) Warning
--- gcc/opts-common.c.jj	2015-12-08 14:25:19.000000000 +0100
+++ gcc/opts-common.c	2015-12-11 16:11:16.499755495 +0100
@@ -1361,7 +1361,13 @@ control_warning_option (unsigned int opt
 			diagnostic_context *dc)
 {
   if (cl_options[opt_index].alias_target != N_OPTS)
-    opt_index = cl_options[opt_index].alias_target;
+    {
+      gcc_assert (!cl_options[opt_index].cl_separate_alias
+		  && !cl_options[opt_index].cl_negative_alias);
+      if (cl_options[opt_index].alias_arg)
+	arg = cl_options[opt_index].alias_arg;
+      opt_index = cl_options[opt_index].alias_target;
+    }
   if (opt_index == OPT_SPECIAL_ignore)
     return;
   if (dc)
--- gcc/c-family/c.opt.jj	2015-12-11 09:24:38.000000000 +0100
+++ gcc/c-family/c.opt	2015-12-11 16:30:40.150547817 +0100
@@ -627,7 +627,7 @@ C++ ObjC++ Var(warn_templates) Warning
 Warn on primary template declaration.
 
 Wmissing-format-attribute
-C ObjC C++ ObjC++ Alias(Wsuggest-attribute=format)
+C ObjC C++ ObjC++ Warning Alias(Wsuggest-attribute=format)
 ;
 
 Wmissing-include-dirs
@@ -678,7 +678,7 @@ C ObjC C++ ObjC++ LangEnabledBy(C ObjC C
 ;
 
 Wnormalized
-C ObjC C++ ObjC++ Alias(Wnormalized=,nfc,none)
+C ObjC C++ ObjC++ Warning Alias(Wnormalized=,nfc,none)
 ;
 
 Wnormalized=
--- gcc/testsuite/c-c++-common/pr68833-1.c.jj	2015-12-11 16:15:14.053446857 +0100
+++ gcc/testsuite/c-c++-common/pr68833-1.c	2015-12-11 16:33:41.593020133 +0100
@@ -0,0 +1,22 @@
+/* PR c/68833 */
+/* { dg-do compile } */
+/* { dg-options "-Werror=larger-than-65536 -Werror=format -Werror=missing-noreturn" } */
+
+int a[131072];	/* { dg-error "size of 'a' is \[1-9]\[0-9]* bytes" } */
+int b[1024];	/* { dg-bogus "size of 'b' is \[1-9]\[0-9]* bytes" } */
+
+void
+f1 (const char *fmt)
+{
+  __builtin_printf ("%d\n", 1.2);	/* { dg-error "expects argument of type" } */
+  __builtin_printf (fmt, 1.2);		/* { dg-bogus "format not a string literal, argument types not checked" } */
+}
+
+extern void f2 (void);
+void
+f2 (void) /* { dg-error "candidate for attribute 'noreturn'" "detect noreturn candidate" } */
+{
+  __builtin_exit (0);
+}
+
+/* { dg-prune-output "treated as errors" } */
--- gcc/testsuite/c-c++-common/pr68833-2.c.jj	2015-12-11 16:27:32.571160818 +0100
+++ gcc/testsuite/c-c++-common/pr68833-2.c	2015-12-11 16:28:15.296565741 +0100
@@ -0,0 +1,16 @@
+/* PR c/68833 */
+/* { dg-do compile } */
+/* { dg-options "-Werror=missing-format-attribute" } */
+
+#include <stdarg.h>
+
+void
+foo (const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  __builtin_vprintf (fmt, ap); /* { dg-error "candidate" "printf attribute warning" } */
+  va_end (ap);
+}
+
+/* { dg-prune-output "treated as errors" } */
--- gcc/testsuite/c-c++-common/pr68833-3.c.jj	2015-12-11 16:38:53.803670711 +0100
+++ gcc/testsuite/c-c++-common/pr68833-3.c	2015-12-11 16:41:28.699512849 +0100
@@ -0,0 +1,7 @@
+/* PR c/68833 */
+/* { dg-do preprocess } */
+/* { dg-options "-Werror=normalized" } */
+
+\u0F43  // { dg-error "`.U00000f43' is not in NFC .-Werror=normalized=." }
+
+/* { dg-prune-output "treated as errors" } */


	Jakub

  reply	other threads:[~2015-12-11 20:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 16:37 [PATCH] Fix -Werror= handling for Joined warnings, add a few missing Warning keywords (PRs c/48088, c/68657) Jakub Jelinek
2015-12-04 17:02 ` Bernd Schmidt
2015-12-04 17:53   ` Jakub Jelinek
2015-12-04 18:20     ` Manuel López-Ibáñez
2015-12-04 19:37       ` Jakub Jelinek
2015-12-07 10:24         ` Bernd Schmidt
2015-12-07 13:45           ` Jakub Jelinek
2015-12-07 15:11             ` Bernd Schmidt
2015-12-07 22:42               ` Jakub Jelinek
2015-12-08 11:56                 ` Bernd Schmidt
2015-12-11 20:18                   ` Jakub Jelinek [this message]
2015-12-14 16:22                     ` [PATCH] Fix -Werror= handling with aliases (PR c/68833) Bernd Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151211201807.GK5675@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=lopezibanez@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).