1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
/* Test for GCC internal format directives.
{ dg-do compile }
{ dg-options "-std=gnu99 -Wformat" } */
/* Magic identifiers must be set before the attribute is used. */
typedef long long __gcc_host_wide_int__;
typedef struct location_s
{
const char *file;
int line;
} location_t;
union tree_node;
typedef union tree_node *tree;
/* Define gcall as a dummy type. The typedef must be provided for
the C test to find the symbol. */
typedef struct gcall gcall;
#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
void diag (const char*, ...) FORMAT (diag);
void cdiag (const char*, ...) FORMAT (cdiag);
void tdiag (const char*, ...) FORMAT (tdiag);
void cxxdiag (const char*, ...) FORMAT (cxxdiag);
void test_diag (tree t, gcall *gc)
{
diag ("%<"); /* { dg-warning "unterminated quoting directive" } */
diag ("%>"); /* { dg-warning "unmatched quoting directive " } */
diag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
diag ("%G", gc);
diag ("%K", t);
diag ("%R"); /* { dg-warning "unmatched color reset directive" } */
diag ("%r", ""); /* { dg-warning "unterminated color directive" } */
diag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
diag ("%r%R", "");
diag ("%r%r%R", "", "");
diag ("%r%R%r%R", "", "");
diag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */
diag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
diag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
diag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
diag ("%<%r%R%>", "");
}
void test_cdiag (tree t, gcall *gc)
{
cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
cdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
cdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cdiag ("%E", t);
cdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
cdiag ("%G", gc);
cdiag ("%K", t);
cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%r%R", "");
cdiag ("%r%r%R", "", "");
cdiag ("%r%R%r%R", "", "");
cdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
cdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
cdiag ("%<%D%>", t);
cdiag ("%<%E%>", t);
cdiag ("%<%F%>", t);
cdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */
cdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%<%r%R%>", "");
cdiag ("%<%T%>", t);
cdiag ("%<%V%>", t);
cdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
cdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
cdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
}
void test_tdiag (tree t, gcall *gc)
{
tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
tdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
tdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
tdiag ("%E", t);
tdiag ("%G", gc);
tdiag ("%K", t);
tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%r%R", "");
tdiag ("%r%R", "");
tdiag ("%r%r%R", "", "");
tdiag ("%r%R%r%R", "", "");
tdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
tdiag ("%<%D%>", t);
tdiag ("%<%E%>", t);
tdiag ("%<%G%>", gc); /* { dg-warning ".G. conversion used within a quoted sequence" } */
tdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%<%r%R%>", "");
tdiag ("%<%T%>", t);
tdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
tdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
tdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
}
void test_cxxdiag (tree t, gcall *gc)
{
cxxdiag ("%A", t); /* { dg-warning ".A. conversion used unquoted" } */
cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cxxdiag ("%E", t);
cxxdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
cxxdiag ("%G", gc);
cxxdiag ("%K", t);
cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
cxxdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
cxxdiag ("%r%R", "");
cxxdiag ("%r%R", "");
cxxdiag ("%r%r%R", "", "");
cxxdiag ("%r%R%r%R", "", "");
cxxdiag ("%S", t); /* { dg-warning ".S. conversion used unquoted" } */
cxxdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
cxxdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
cxxdiag ("%X", t); /* { dg-warning ".X. conversion used unquoted" } */
cxxdiag ("%<%A%>", t);
cxxdiag ("%<%D%>", t);
cxxdiag ("%<%E%>", t);
cxxdiag ("%<%F%>", t);
cxxdiag ("%<%R%>"); /* { dg-warning "unmatched color reset" } */
cxxdiag ("%<%r%R%>", "");
cxxdiag ("%<%S%>", t);
cxxdiag ("%<%T%>", t);
cxxdiag ("%<%V%>", t);
cxxdiag ("%<%X%>", t);
}
|