1 /* Test for GCC internal format directives.
3 { dg-options "-std=gnu99 -Wformat" } */
5 /* Magic identifiers must be set before the attribute is used. */
7 typedef long long __gcc_host_wide_int__
;
9 typedef struct location_s
16 typedef union tree_node
*tree
;
18 /* Define gimple as a dummy type. The typedef must be provided for
19 the C test to find the symbol. */
20 typedef struct gimple gimple
;
22 #define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
24 void diag (const char*, ...) FORMAT (diag
);
25 void cdiag (const char*, ...) FORMAT (cdiag
);
26 void tdiag (const char*, ...) FORMAT (tdiag
);
27 void cxxdiag (const char*, ...) FORMAT (cxxdiag
);
29 void test_diag (tree t
, gimple
*gc
)
31 diag ("%<"); /* { dg-warning "unterminated quoting directive" } */
32 diag ("%>"); /* { dg-warning "unmatched quoting directive " } */
33 diag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
35 diag ("%G", gc
); /* { dg-warning "format" } */
36 diag ("%K", t
); /* { dg-warning "format" } */
38 diag ("%R"); /* { dg-warning "unmatched color reset directive" } */
39 diag ("%r", ""); /* { dg-warning "unterminated color directive" } */
40 diag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
42 diag ("%r%r%R", "", "");
43 diag ("%r%R%r%R", "", "");
45 diag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
46 diag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
47 diag ("%<%r%R%>", "");
50 void test_cdiag (tree t
, gimple
*gc
)
52 cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
53 cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
54 cdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
56 cdiag ("%D", t
); /* { dg-warning ".D. conversion used unquoted" } */
58 cdiag ("%F", t
); /* { dg-warning ".F. conversion used unquoted" } */
62 cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
63 cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
64 cdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
66 cdiag ("%r%r%R", "", "");
67 cdiag ("%r%R%r%R", "", "");
69 cdiag ("%T", t
); /* { dg-warning ".T. conversion used unquoted" } */
70 cdiag ("%V", t
); /* { dg-warning ".V. conversion used unquoted" } */
75 cdiag ("%<%G%>", gc
); /* { dg-warning ".G. conversion used within a quoted sequence" } */
76 cdiag ("%<%K%>", t
); /* { dg-warning ".K. conversion used within a quoted sequence" } */
78 cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
79 cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
80 cdiag ("%<%r%R%>", "");
85 cdiag ("%<%qD%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
86 cdiag ("%<%qE%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
87 cdiag ("%<%qT%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
90 void test_tdiag (tree t
, gimple
*gc
)
92 tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
93 tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
94 tdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
96 tdiag ("%D", t
); /* { dg-warning ".D. conversion used unquoted" } */
101 tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
102 tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
103 tdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
106 tdiag ("%r%r%R", "", "");
107 tdiag ("%r%R%r%R", "", "");
109 tdiag ("%T", t
); /* { dg-warning ".T. conversion used unquoted" } */
113 tdiag ("%<%G%>", gc
); /* { dg-warning ".G. conversion used within a quoted sequence" } */
114 tdiag ("%<%K%>", t
); /* { dg-warning ".K. conversion used within a quoted sequence" } */
116 tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
117 tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
118 tdiag ("%<%r%R%>", "");
122 tdiag ("%<%qD%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
123 tdiag ("%<%qE%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
124 tdiag ("%<%qT%>", t
); /* { dg-warning ".q. flag used within a quoted sequence" } */
127 void test_cxxdiag (tree t
, gimple
*gc
)
129 cxxdiag ("%A", t
); /* { dg-warning ".A. conversion used unquoted" } */
130 cxxdiag ("%D", t
); /* { dg-warning ".D. conversion used unquoted" } */
132 cxxdiag ("%F", t
); /* { dg-warning ".F. conversion used unquoted" } */
136 cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
137 cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
138 cxxdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
139 cxxdiag ("%r%R", "");
140 cxxdiag ("%r%R", "");
141 cxxdiag ("%r%r%R", "", "");
142 cxxdiag ("%r%R%r%R", "", "");
144 cxxdiag ("%S", t
); /* { dg-warning ".S. conversion used unquoted" } */
145 cxxdiag ("%T", t
); /* { dg-warning ".T. conversion used unquoted" } */
146 cxxdiag ("%V", t
); /* { dg-warning ".V. conversion used unquoted" } */
147 cxxdiag ("%X", t
); /* { dg-warning ".X. conversion used unquoted" } */
149 cxxdiag ("%<%A%>", t
);
150 cxxdiag ("%<%D%>", t
);
151 cxxdiag ("%<%E%>", t
);
152 cxxdiag ("%<%F%>", t
);
153 cxxdiag ("%<%R%>"); /* { dg-warning "unmatched color reset" } */
154 cxxdiag ("%<%r%R%>", "");
155 cxxdiag ("%<%S%>", t
);
156 cxxdiag ("%<%T%>", t
);
157 cxxdiag ("%<%V%>", t
);
158 cxxdiag ("%<%X%>", t
);