diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/format1.C')
-rw-r--r-- | gcc/testsuite/g++.dg/warn/format1.C | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/format1.C b/gcc/testsuite/g++.dg/warn/format1.C new file mode 100644 index 000000000..27bc414b0 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/format1.C @@ -0,0 +1,15 @@ +// Test that formats get checked according to C94. +// Origin: Joseph Myers <jsm28@cam.ac.uk>. +// { dg-do compile } +// { dg-options "-ansi -pedantic -Wformat" } + +#include <cstdio> + +void +foo (int i, int *ip, __WINT_TYPE__ lc, wchar_t *ls) +{ + std::printf ("%d%ls%lc\n", i, ls, lc); + std::printf ("%d", ls); // { dg-warning "format" "printf warning" } + std::scanf ("%d%lc%ls%l[abc]", ip, ls, ls, ls); + std::scanf ("%hd", ip); // { dg-warning "format" "scanf warning" } +} |