]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/67854 (Missing diagnostic for passing bool to va_arg)
authorMarek Polacek <polacek@redhat.com>
Wed, 2 Mar 2016 07:24:19 +0000 (07:24 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 2 Mar 2016 07:24:19 +0000 (07:24 +0000)
PR c/67854
* gimplify.c (gimplify_va_arg_expr): Use expanded location for the
"is promoted to" warning.

* gcc.dg/pr67854.c: New test.

From-SVN: r233891

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr67854.c [new file with mode: 0644]

index 3bfb21030ffe0488c11fcf6e05d45b55d358813e..63a76742472db3d7e278b81770a5731a3ad2cf13 100644 (file)
@@ -1,3 +1,9 @@
+2016-03-02  Marek Polacek  <polacek@redhat.com>
+
+       PR c/67854
+       * gimplify.c (gimplify_va_arg_expr): Use expanded location for the
+       "is promoted to" warning.
+
 2016-03-01  DJ Delorie  <dj@redhat.com>
 
        * config.gcc: Deprecate mep-*.
index 7be6bd708f1ebcd4ea3800fe228eb263e81aeb75..e7ea974496dd4db4994c1acee630de7ffb4fe6e3 100644 (file)
@@ -11573,24 +11573,28 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p,
     {
       static bool gave_help;
       bool warned;
+      /* Use the expansion point to handle cases such as passing bool (defined
+        in a system header) through `...'.  */
+      source_location xloc
+       = expansion_point_location_if_in_system_header (loc);
 
       /* Unfortunately, this is merely undefined, rather than a constraint
         violation, so we cannot make this an error.  If this call is never
         executed, the program is still strictly conforming.  */
-      warned = warning_at (loc, 0,
-                          "%qT is promoted to %qT when passed through %<...%>",
+      warned = warning_at (xloc, 0,
+                          "%qT is promoted to %qT when passed through %<...%>",
                           type, promoted_type);
       if (!gave_help && warned)
        {
          gave_help = true;
-         inform (loc, "(so you should pass %qT not %qT to %<va_arg%>)",
+         inform (xloc, "(so you should pass %qT not %qT to %<va_arg%>)",
                  promoted_type, type);
        }
 
       /* We can, however, treat "undefined" any way we please.
         Call abort to encourage the user to fix the program.  */
       if (warned)
-       inform (loc, "if this code is reached, the program will abort");
+       inform (xloc, "if this code is reached, the program will abort");
       /* Before the abort, allow the evaluation of the va_list
         expression to exit or longjmp.  */
       gimplify_and_add (valist, pre_p);
index 321c87e27873f1f8a288d2adb71a3f55418b503f..90282805b0080718439c4f2f16c104ef863e29ce 100644 (file)
@@ -1,3 +1,8 @@
+2016-03-02  Marek Polacek  <polacek@redhat.com>
+
+       PR c/67854
+       * gcc.dg/pr67854.c: New test.
+
 2016-03-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/70025
diff --git a/gcc/testsuite/gcc.dg/pr67854.c b/gcc/testsuite/gcc.dg/pr67854.c
new file mode 100644 (file)
index 0000000..af994c6
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/67854 */
+/* { dg-do compile } */
+
+#include <stdbool.h>
+#include <stdarg.h>
+
+void
+foo (va_list ap)
+{
+  va_arg (ap, bool); /* { dg-warning "is promoted to .int. when passed through" } */
+}