d: Add -Wvarargs warning flag to the D front-end
The D front-end has C-style variadic functions and va_start/va_arg, so it is right to also have warnings for inproper use. gcc/d/ChangeLog: PR d/96154 * gdc.texi (Warnings): Document -Wvarargs. * lang.opt: Add -Wvarargs gcc/testsuite/ChangeLog: PR d/96154 * gdc.dg/pr96154a.d: New test. * gdc.dg/pr96154b.d: New test.
This commit is contained in:
parent
dfc420f8d4
commit
873b45d39c
|
@ -600,6 +600,12 @@ Warn when a @code{pragma()} is encountered that is not understood by
|
||||||
where a pragma that is part of the D language, but not implemented by
|
where a pragma that is part of the D language, but not implemented by
|
||||||
the compiler, won't get reported.
|
the compiler, won't get reported.
|
||||||
|
|
||||||
|
@item -Wno-varargs
|
||||||
|
@cindex Wvarargs
|
||||||
|
@cindex Wno-varargs
|
||||||
|
Do not warn upon questionable usage of the macros used to handle variable
|
||||||
|
arguments like @code{va_start}.
|
||||||
|
|
||||||
@item -fignore-unknown-pragmas
|
@item -fignore-unknown-pragmas
|
||||||
@cindex @option{-fignore-unknown-pragmas}
|
@cindex @option{-fignore-unknown-pragmas}
|
||||||
@cindex @option{-fno-ignore-unknown-pragmas}
|
@cindex @option{-fno-ignore-unknown-pragmas}
|
||||||
|
|
|
@ -146,6 +146,10 @@ Wunknown-pragmas
|
||||||
D LangEnabledBy(D, Wall)
|
D LangEnabledBy(D, Wall)
|
||||||
; Documented in C
|
; Documented in C
|
||||||
|
|
||||||
|
Wvarargs
|
||||||
|
D
|
||||||
|
; Documented in C
|
||||||
|
|
||||||
X
|
X
|
||||||
D
|
D
|
||||||
Generate JSON file.
|
Generate JSON file.
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
import core.stdc.stdarg;
|
||||||
|
|
||||||
|
void
|
||||||
|
error (int a)
|
||||||
|
{
|
||||||
|
va_list vp;
|
||||||
|
va_start (vp, a); // { dg-error "used in function with fixed arguments" }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn (int a, int b, ...)
|
||||||
|
{
|
||||||
|
va_list vp;
|
||||||
|
va_start (vp, a); // { dg-warning "second parameter" }
|
||||||
|
va_end (vp);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
// { dg-options "-Wno-varargs" }
|
||||||
|
// { dg-do compile }
|
||||||
|
|
||||||
|
import core.stdc.stdarg;
|
||||||
|
|
||||||
|
void
|
||||||
|
error (int a)
|
||||||
|
{
|
||||||
|
va_list vp;
|
||||||
|
va_start (vp, a); // { dg-error "used in function with fixed arguments" }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
warn (int a, int b, ...)
|
||||||
|
{
|
||||||
|
va_list vp;
|
||||||
|
va_start (vp, a); // No warning because of -Wno-varargs in effect.
|
||||||
|
va_end (vp);
|
||||||
|
}
|
Loading…
Reference in New Issue