annotate gcc/testsuite/gcc.dg/format/null-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for some aspects of null format string handling. */
kono
parents:
diff changeset
2 /* Origin: Jason Thorpe <thorpej@wasabisystems.com> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-std=gnu99 -Wformat" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 #define DONT_GNU_PROTOTYPE
kono
parents:
diff changeset
7 #include "format.h"
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 extern void my_printf (const char *, ...) __attribute__((format(gnu_attr_printf,1,2)));
kono
parents:
diff changeset
10 extern const char *my_format (const char *, const char *)
kono
parents:
diff changeset
11 __attribute__((format_arg(2)));
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 void
kono
parents:
diff changeset
14 foo (int i1)
kono
parents:
diff changeset
15 {
kono
parents:
diff changeset
16 /* Warning about a null format string has been decoupled from the actual
kono
parents:
diff changeset
17 format check. However, we still expect to be warned about any excess
kono
parents:
diff changeset
18 arguments after a null format string. */
kono
parents:
diff changeset
19 my_printf (NULL);
kono
parents:
diff changeset
20 my_printf (NULL, i1); /* { dg-warning "too many" "null format with arguments" } */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 my_printf (my_format ("", NULL));
kono
parents:
diff changeset
23 my_printf (my_format ("", NULL), i1); /* { dg-warning "too many" "null format_arg with arguments" } */
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 /* While my_printf allows a null argument, dgettext does not, so we expect
kono
parents:
diff changeset
26 a null argument warning here. */
kono
parents:
diff changeset
27 my_printf (dgettext ("", NULL)); /* { dg-warning "null" "null format with dgettext" } */
kono
parents:
diff changeset
28 }