(check_format): For scan of "%["...
authorRichard Stallman <rms@gnu.org>
Sat, 14 Aug 1993 03:22:24 +0000 (03:22 +0000)
committerRichard Stallman <rms@gnu.org>
Sat, 14 Aug 1993 03:22:24 +0000 (03:22 +0000)
(check_format): For scan of "%[", skip over scan set
til closing ']' to avoid processing it as ordinary format characters.

From-SVN: r5160

gcc/c-typeck.c

index 2088f00f8e6762310348a91567207f651ad2c2f6..04799655bf1a2f61e195437c57a2010ef80a9687 100644 (file)
@@ -1716,6 +1716,21 @@ check_format (info, params)
                   format_char);
          warning (message);
        }
+      if (info->is_scan && format_char == '[')
+       {
+         /* Skip over scan set, in case it happens to have '%' in it.  */
+         if (*format_chars == '^')
+           ++format_chars;
+         /* Find closing bracket; if one is hit immediately, then
+            it's part of the scan set rather than a terminator.  */
+         if (*format_chars == ']')
+           ++format_chars;
+         while (*format_chars && *format_chars != ']')
+           ++format_chars;
+         if (*format_chars != ']')
+             /* The end of the format string was reached.  */
+             warning ("no closing `]' for `%%[' format");
+       }
       if (suppressed)
        {
          if (index (fci->flag_chars, '*') == 0)