aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDan Hipschman <dsh@google.com>2007-08-13 14:55:01 -0700
committerDan Hipschman <dsh@gcc.gnu.org>2007-08-13 14:55:01 -0700
commitd46571c803a80a1ee0b7360f0667a8e315a9b959 (patch)
tree278e6dbd480b49a8489a8b858c2faeb7bea5386b /gcc
parenteda0ed2597cfab9c967d229b7df2986ef92e663d (diff)
downloadgcc-d46571c803a80a1ee0b7360f0667a8e315a9b959.zip
gcc-d46571c803a80a1ee0b7360f0667a8e315a9b959.tar.gz
gcc-d46571c803a80a1ee0b7360f0667a8e315a9b959.tar.bz2
2007-08-3 1 Dan Hipschman <dsh@google.com>
gcc/ 2007-08-3 1 Dan Hipschman <dsh@google.com> PR 32953 * c-format.c (check_format_arg): Move check for zero-length format strings below the check for unterminated strings. testsuite/ 2007-08-13 Dan Hipschman <dsh@google.com> PR 32953 * gcc.dg/format/array-1.c: Add an additional test for unterminated format strings of length 1. From-SVN: r127399
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-format.c9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/format/array-1.c6
4 files changed, 18 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a2f9281..186a050 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-13 Dan Hipschman <dsh@google.com>
+
+ PR c/32953
+ * c-format.c (check_format_arg): Move check for zero-length
+ format strings below the check for unterminated strings.
+
2007-08-13 Andrew Pinski <pinskia@gmail.com>
PR C/30427
diff --git a/gcc/c-format.c b/gcc/c-format.c
index 8a36dd4..a496541 100644
--- a/gcc/c-format.c
+++ b/gcc/c-format.c
@@ -1401,21 +1401,16 @@ check_format_arg (void *ctx, tree format_tree,
format_chars += offset;
format_length -= offset;
}
- if (format_length < 1)
+ if (format_length < 1 || format_chars[--format_length] != 0)
{
res->number_unterminated++;
return;
}
- if (format_length == 1)
+ if (format_length == 0)
{
res->number_empty++;
return;
}
- if (format_chars[--format_length] != 0)
- {
- res->number_unterminated++;
- return;
- }
/* Skip to first argument to check. */
while (arg_num + 1 < info->first_arg_num)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9595f222..8b1e57f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2007-08-13 Dan Hipschman <dsh@google.com>
+
+ PR c/32953
+ * gcc.dg/format/array-1.c: Add an additional test for
+ unterminated format strings of length 1.
+
2007-08-13 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32926
diff --git a/gcc/testsuite/gcc.dg/format/array-1.c b/gcc/testsuite/gcc.dg/format/array-1.c
index fa27abe..14db56e 100644
--- a/gcc/testsuite/gcc.dg/format/array-1.c
+++ b/gcc/testsuite/gcc.dg/format/array-1.c
@@ -7,7 +7,8 @@
const char a1[] = "foo";
const char a2[] = "foo%d";
-const char b[3] = "foo";
+const char b1[3] = "foo";
+const char b2[1] = "1";
static const char c1[] = "foo";
static const char c2[] = "foo%d";
char d[] = "foo";
@@ -23,7 +24,8 @@ foo (int i, long l)
printf (a1);
printf (a2, i);
printf (a2, l); /* { dg-warning "format" "wrong type with array" } */
- printf (b); /* { dg-warning "unterminated" "unterminated array" } */
+ printf (b1); /* { dg-warning "unterminated" "unterminated array" } */
+ printf (b2); /* { dg-warning "unterminated" "unterminated array" } */
printf (c1);
printf (c2, i);
printf (c2, l); /* { dg-warning "format" "wrong type with array" } */