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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
/* Verify that calling strndup and strnlen with an unknown bound isn't
diagnosed regardless of the size of the array and the type of the bound.
{ dg-do compile }
{ dg-options "-O -Wall" } */
#define NOIPA __attribute__ ((noipa))
typedef __SIZE_TYPE__ size_t;
extern char* strndup (const char*, size_t);
extern size_t strnlen (const char*, size_t);
/* TO DO: Passing a zero-length array to any function is almost certainly
a bug and should be diagnosed except perpaphs when the function also
takes a bound and its value is known to be zero. When this is
implemented this test will need to be adjusted. */
extern char a0[0];
extern char a1[1];
NOIPA char* strndup_a0_si (short n)
{
return strndup (a0, n);
}
NOIPA char* strndup_a0_i (int n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a0_li (long n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a0_lli (long long n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a0_usi (unsigned short n)
{
return strndup (a0, n);
}
NOIPA char* strndup_a0_ui (unsigned n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a0_uli (unsigned long n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a0_ulli (unsigned long long n)
{
return strndup (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_si (short n)
{
return strndup (a1, n);
}
NOIPA char* strndup_a1_i (int n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_li (long n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_lli (long long n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_usi (unsigned short n)
{
return strndup (a1, n);
}
NOIPA char* strndup_a1_ui (unsigned n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_uli (unsigned long n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA char* strndup_a1_ulli (unsigned long long n)
{
return strndup (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_si (short n)
{
return strnlen (a0, n);
}
NOIPA size_t strnlen_a0_i (int n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_li (long n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_lli (long long n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_usi (unsigned short n)
{
return strnlen (a0, n);
}
NOIPA size_t strnlen_a0_ui (unsigned n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_uli (unsigned long n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a0_ulli (unsigned long long n)
{
return strnlen (a0, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_si (short n)
{
return strnlen (a1, n);
}
NOIPA size_t strnlen_a1_i (int n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_li (long n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_lli (long long n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_usi (unsigned short n)
{
return strnlen (a1, n);
}
NOIPA size_t strnlen_a1_ui (unsigned n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_uli (unsigned long n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
NOIPA size_t strnlen_a1_ulli (unsigned long long n)
{
return strnlen (a1, n); // { dg-bogus "\\\[-Wstringop-overread" }
}
|