]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c/68833 (-Werror=format issues an error now)
authorJakub Jelinek <jakub@redhat.com>
Mon, 14 Dec 2015 16:59:05 +0000 (17:59 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 14 Dec 2015 16:59:05 +0000 (17:59 +0100)
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.

From-SVN: r231624

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/common.opt
gcc/opts-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr68833-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr68833-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr68833-3.c [new file with mode: 0644]

index 14efd7a35b0f8a50474e90e13efd57e23ca99999..31c79d87c19403469908e4398e2f3525acb2a92f 100644 (file)
@@ -1,3 +1,10 @@
+2015-12-14  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.
+
 2015-12-14  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR target/68865
index 0f557c77e61f9e182b390efadc732152f695816e..db9a279c20f27ae9783f03196ee7e81ce1171dfc 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/68833
+       * c.opt (Wmissing-format-attribute, Wnormalized): Add Warning option.
+
 2014-12-12  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/68815
index 5867de527fd74dd56bf40922eb909c6ce35ea7f2..70dc91614b92fa77ac7c2f921965d542e3bb5549 100644 (file)
@@ -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++ ObjC++,Wall)
 ;
 
 Wnormalized
-C ObjC C++ ObjC++ Alias(Wnormalized=,nfc,none)
+C ObjC C++ ObjC++ Warning Alias(Wnormalized=,nfc,none)
 ;
 
 Wnormalized=
index b1591d5d49b0658daa5131eb7c55753149064554..6264bc03bcabdd45193466029a891e8913d439ab 100644 (file)
@@ -612,7 +612,7 @@ Common Var(warn_unsafe_loop_optimizations) Warning
 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
index 507358a1d17d5f95772c8d7286145d03f680441e..55b631586b5412781513fce89ca010eafba1250d 100644 (file)
@@ -1361,7 +1361,13 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg,
                        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)
index 45db39a777eff37dc38e4f1b52d5b89058240b46..2bbd9dcc2dd2cb02bd5316a91ea1abb1cb09e947 100644 (file)
@@ -1,3 +1,9 @@
+2015-12-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/68833
+       * c-c++-common/pr68833-1.c: New test.
+       * c-c++-common/pr68833-2.c: New test.
+
 2015-12-14  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/68852
diff --git a/gcc/testsuite/c-c++-common/pr68833-1.c b/gcc/testsuite/c-c++-common/pr68833-1.c
new file mode 100644 (file)
index 0000000..e0601b3
--- /dev/null
@@ -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" } */
diff --git a/gcc/testsuite/c-c++-common/pr68833-2.c b/gcc/testsuite/c-c++-common/pr68833-2.c
new file mode 100644 (file)
index 0000000..c991b7a
--- /dev/null
@@ -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" } */
diff --git a/gcc/testsuite/c-c++-common/pr68833-3.c b/gcc/testsuite/c-c++-common/pr68833-3.c
new file mode 100644 (file)
index 0000000..c99a2c6
--- /dev/null
@@ -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" } */
This page took 0.137187 seconds and 5 git commands to generate.