aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-01-28 00:09:15 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-01-27 17:09:15 -0700
commiteb339366496c247f8d9667c58922eac8a870222b (patch)
treeaa7244f6c38a1687a364a85a09a97954464bef5a
parent1f44286be085afc84e107f02c6e436c99eb69a3d (diff)
downloadgcc-eb339366496c247f8d9667c58922eac8a870222b.zip
gcc-eb339366496c247f8d9667c58922eac8a870222b.tar.gz
gcc-eb339366496c247f8d9667c58922eac8a870222b.tar.bz2
builtin-sprintf-warn-1.c: Add test cases.
gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Add test cases. From-SVN: r244999
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c18
2 files changed, 20 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eb63091..f4b6aa0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-01-27 Martin Sebor <msebor@redhat.com>
+
+ * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Add test cases.
+
2017-01-27 Bernd Schmidt <bschmidt@redhat.com>
PR rtl-optimization/79194
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
index 0f3d423..9955326 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-1.c
@@ -76,10 +76,24 @@ int dummy___vsnprintf_chk (char*, size_t, int, size_t, const char*, va_list);
/* Macro to verify that calls to __builtin_sprintf (i.e., with no size
argument) issue diagnostics by correctly determining the size of
the destination buffer. */
-#define T(size, fmt, ...) \
- (FUNC (sprintf) (buffer (size), fmt, __VA_ARGS__), \
+#define T(size, ...) \
+ (FUNC (sprintf) (buffer (size), __VA_ARGS__), \
sink (buffer, ptr))
+/* Exercise the "%%" directive. */
+
+void test_sprintf_percent (void)
+{
+ T (-1, "%%");
+ T ( 0, "%%"); /* { dg-warning ".%%. directive writing 1 byte into a region of size 0" } */
+ T ( 1, "%%"); /* { dg-warning "writing a terminating nul past the end" } */
+ T ( 2, "%%");
+ T ( 2, "%%%%"); /* { dg-warning "writing a terminating nul past the end" } */
+ T ( 3, "%%%%");
+ T ( 3, "%%X%%"); /* { dg-warning "writing a terminating nul past the end" } */
+ T ( 4, "%%X%%");
+}
+
/* Exercise the "%c" and "%lc" directive with constant arguments. */
void test_sprintf_c_const (void)