+2012-04-30 Dodji Seketeli <dodji@redhat.com>
+
+ Add -Wvarargs option
+ * builtins.c (fold_builtin_next_arg): Use OPT_Wvarargs as an
+ argument for the various warning_at calls.
+ * docs/invoke.texi: Update the documentation.
+
2012-04-30 Dodji Seketeli <dodji@redhat.com>
Switch -ftrack-macro-expansion=2 on by default.
/* Evidently an out of date version of <stdarg.h>; can't validate
va_start's second argument, but can still work as intended. */
warning_at (current_location,
- 0,
- "%<__builtin_next_arg%> called without an argument");
+ OPT_Wvarargs,
+ "%<__builtin_next_arg%> called without an argument");
return true;
}
else if (nargs > 1)
argument so that we will get wrong-code because of
it. */
warning_at (current_location,
- 0,
+ OPT_Wvarargs,
"second parameter of %<va_start%> not last named argument");
}
else if (DECL_REGISTER (arg))
{
warning_at (current_location,
- 0,
+ OPT_Wvarargs,
"undefined behaviour when second parameter of "
"%<va_start%> is declared with %<register%> storage");
}
+2012-04-30 Dodji Seketeli <dodji@redhat.com>
+
+ Add -Wvarargs option
+ * c.opt (Wvarargs): Define new option.
+
2012-04-30 Manuel López-Ibáñez <manu@gcc.gnu.org>
* c-common.c (check_function_arguments): Replace
C ObjC C++ ObjC++ Warning
Do not warn about using variadic macros when -pedantic
+Wvarargs
+C ObjC C++ ObjC++ Warning Var(warn_varargs) Init(1)
+Warn about questionable usage of the macros used to retrieve variable arguments
+
Wvla
C ObjC C++ ObjC++ Var(warn_vla) Init(-1) Warning
Warn if a variable length array is used
alternate syntax when in pedantic ISO C99 mode. This is default.
To inhibit the warning messages, use @option{-Wno-variadic-macros}.
+@item -Wvarargs
+@opindex Wvarargs
+@opindex Wno-varargs
+Warn upon questionable usage of the macros used to handle variable
+arguments like @samp{va_start}. This is default. To inhibit the
+warning messages, use @option{-Wno-varargs}.
+
@item -Wvector-operation-performance
@opindex Wvector-operation-performance
@opindex Wno-vector-operation-performance
+2012-04-30 Dodji Seketeli <dodji@redhat.com>
+
+ Add -Wvarargs option
+ * c-c++-common/Wvarargs.c: New test case.
+ * c-c++-common/Wvarargs-2.c: Likewise.
+
2012-04-30 Dodji Seketeli <dodji@redhat.com>
Adjust relevant test cases wrt -ftrack-macro-expansion=[0|2]
--- /dev/null
+/*
+ { dg-options "-Wno-varargs" }
+ { dg-do compile }
+ */
+
+#include <stdarg.h>
+
+void
+err (int a)
+{
+ va_list vp;
+ va_start (vp, a); // { dg-error "used in function with fixed args" }
+}
+
+void
+foo0 (int a, int b, ...)
+{
+ va_list vp;
+ /* 'a' is not the last argument of the enclosing function, but
+ don't warn because we are ignoring -Wvarargs. */
+ va_start (vp, a);
+ va_end (vp);
+}
+
+void
+foo1 (int a, register int b, ...)
+{
+ va_list vp;
+ /* 'b' is declared with register storage, but don't warn
+ because we are ignoring -Wvarargs. */
+ va_start (vp, b);
+ va_end (vp);
+}
--- /dev/null
+/* { dg-do compile } */
+
+#include <stdarg.h>
+
+void
+err (int a)
+{
+ va_list vp;
+ va_start (vp, a); // { dg-error "used in function with fixed args" }
+}
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wvarargs"
+
+void
+foo0 (int a, int b, ...)
+{
+ va_list vp;
+ /* 'a' is not the last argument of the enclosing function, but
+ don't warn because we are ignoring -Wvarargs. */
+ va_start (vp, a);
+ va_end (vp);
+}
+
+void
+foo1 (int a, register int b, ...)
+{
+ va_list vp;
+ /* 'b' is declared with register storage, but don't warn
+ because we are ignoring -Wvarargs. */
+ va_start (vp, b);
+ va_end (vp);
+}
+
+#pragma GCC diagnostic pop
+
+void
+foo2 (int a, int b, ...)
+{
+ va_list vp;
+ /* 'a' is not the last argument of the enclosing function, so
+ warn. */
+ va_start (vp, a); /* { dg-warning "second parameter" } */
+ va_end (vp);
+}
+
+void
+foo3 (int a, register int b, ...)
+{
+ va_list vp;
+ /* 'b' is declared with register storage, so warn. */
+ va_start (vp, b); /* { dg-warning "undefined behaviour" } */
+ va_end (vp);
+}