sink (p);
++idx;
- memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" "pr?????" { xfail ilp32 } }
+ memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 1" }
+ sink (p);
++idx;
memset (p + idx, 0, 3); // { dg-warning "writing 3 bytes into a region of size 0" }
{
if (i < 1) i = 1;
d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail ilp32 } }
+ d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { xfail { ! lp64 } } }
}
void cpy_sl_1_max (long i, const char *s)
{
if (i < 1) i = 1;
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+ d = strcpy (a + i + 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
}
void cpy_ul_1_max (unsigned long i, const char *s)
{
if (i < 1) i = 1;
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
/* Because of integer wraparound the offset's range is [1, 0] so
the overflow isn't diagnosed (yet). */
void cpy_sl_min_m1 (long i, const char *s)
{
if (i > -1) i = -1;
- d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
- d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" }
+ d = strcpy (a + i - 1, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
+ d = strcpy (a + i, s); // { dg-warning "writing 1 or more bytes into a region of size 0" "" { target { ! ptr_eq_short } } }
d = strcpy (a + i + 2, s);
}
void warn_comp_lit (void)
{
- *(AC2*)a1 = Ac2; // { dg-warning "writing 2 bytes into a region of size 1" "pr??????" { xfail *-*-* } }
- *(AC4*)a2 = Ac4; // { dg-warning "writing 4 bytes into a region of size 2" "pr??????" { xfail *-*-* } }
- *(AC4*)a3 = Ac4; // { dg-warning "writing 4 bytes into a region of size 3" "pr??????" { xfail *-*-* } }
- *(AC8*)a4 = Ac8; // { dg-warning "writing 8 bytes into a region of size 4" "pr??????" { xfail *-*-* } }
- *(AC8*)a7 = Ac8; // { dg-warning "writing 8 bytes into a region of size 7" "pr??????" { xfail *-*-* } }
- *(AC16*)a15 = Ac16; // { dg-warning "writing 16 bytes into a region of size 15" "pr??????" { xfail *-*-* } }
+ *(AC2*)a1 = Ac2; // { dg-warning "writing 2 bytes into a region of size 1" "pr101475" { xfail *-*-* } }
+ *(AC4*)a2 = Ac4; // { dg-warning "writing 4 bytes into a region of size 2" "pr101475" { xfail *-*-* } }
+ *(AC4*)a3 = Ac4; // { dg-warning "writing 4 bytes into a region of size 3" "pr101475" { xfail *-*-* } }
+ *(AC8*)a4 = Ac8; // { dg-warning "writing 8 bytes into a region of size 4" "pr101475" { xfail *-*-* } }
+ *(AC8*)a7 = Ac8; // { dg-warning "writing 8 bytes into a region of size 7" "pr101475" { xfail *-*-* } }
+ *(AC16*)a15 = Ac16; // { dg-warning "writing 16 bytes into a region of size 15" "pr101475" { xfail *-*-* } }
}
void warn_aggr_decl (void)
{
char *p = __builtin_malloc (15);
for (int i = 0; i != 16; ++i)
- p[i] = i; // { dg-warning "writing 16 bytes into a region of size 15" }
+ /* The size of the write below depends on the target. When vectorized
+ the vector size may be 4 or 16, otherwise it may be a series of byte
+ assignments. */
+ p[i] = i; // { dg-warning "writing (1|2|4|16) bytes? into a region of size (0|1|3|15)" }
return p;
}
extern void* alloca (size_t);
extern double nan (const char *);
-_Decimal32 nand32 (const char *);
+
+#ifdef __DEC32_MAX__
+ _Decimal32 nand32 (const char *);
+#else
+/* _Decimal32 is supported only conditionally and not available on all
+ targets. */
+# define _Decimal32 double
+# define nand32(s) nan (s)
+#endif
extern size_t strlen (const char *);
extern char* strcpy (char *, const char *);
}
-void nowarn_nan (const char *s)
+__attribute__ ((noipa)) void nowarn_nan (const char *s)
{
*(double *)ax = nan (s);
}
-void warn_nan (const char *s)
+__attribute__ ((noipa)) void warn_nan (const char *s)
{
*(double *)a1 = nan (s); // { dg-warning "\\\[-Wstringop-overflow" }
}
-void nowarn_nand32 (const char *s)
+__attribute__ ((noipa)) void nowarn_nand32 (const char *s)
{
*(_Decimal32 *)ax = nand32 (s);
}
-void warn_nand32 (const char *s)
+__attribute__ ((noipa)) void warn_nand32 (const char *s)
{
*(_Decimal32 *)a1 = nand32 (s); // { dg-warning "\\\[-Wstringop-overflow" }
}
void warn_strlen (const char *s1, const char *s2)
{
*(int16_t *)a1 = strlen (s1); // { dg-warning "\\\[-Wstringop-overflow" }
- *(size_t *)a2 = strlen (s2); // { dg-warning "\\\[-Wstringop-overflow" }
+ *(size_t *)a2 = strlen (s2); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
}
void warn_strcpy (char *s1, char *s2, const char *s3)
{
*(char **)a1 = strcpy (s1, s2); // { dg-warning "\\\[-Wstringop-overflow" }
- *(char **)a2 = strcpy (s2, s3); // { dg-warning "\\\[-Wstringop-overflow" }
+ *(char **)a2 = strcpy (s2, s3); // { dg-warning "\\\[-Wstringop-overflow" "!ptr_eq_short" { target { ! ptr_eq_short } } }
}
/* Verify strlen results of vector assignments.
{ dg-do compile }
- { dg-options "-O2 -Wall" } */
+ { dg-options "-O2 -Wall -fdump-tree-optimized" } */
#include "strlenopt.h"
*(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6 };
A (strlen (a) == 3);
- *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7 };
+ *(VC8*)a = (VC8){ 1, 2, 3, 0, 5, 6, 7, 8 };
A (strlen (a) == 3);
A (strlen (a + 1) == 2);
A (strlen (a + 2) == 1);
A (a[4] == 5 && a[5] == 6 && a[6] == 7 && a[7] == 8);
}
-/* { dg-final { scan-tree-dump-not "abort \\(" "strlen1" } }
- { dg-final { scan-tree-dump-not "strlen \\(" "strlen1" } } */
+/* { dg-final { scan-tree-dump-not "abort \\(" "optimized" } }
+ { dg-final { scan-tree-dump-not "strlen \\(" "optimized" } } */