]> gcc.gnu.org Git - gcc.git/commitdiff
Warray-bounds-2.c: Include headers only if they exist.
authorMartin Sebor <msebor@gcc.gnu.org>
Wed, 23 Jan 2019 00:23:21 +0000 (17:23 -0700)
committerMartin Sebor <msebor@gcc.gnu.org>
Wed, 23 Jan 2019 00:23:21 +0000 (17:23 -0700)
gcc/testsuite/ChangeLog:

* c-c++-common/Warray-bounds-2.c: Include headers only if they exist.
* c-c++-common/Warray-bounds-3.c: Make xfails conditional on target
non_strict_align.
* c-c++-common/Wrestrict-2.c: Include headers only if they exist.
* c-c++-common/Wrestrict.c: Make xfails conditional on target
non_strict_align.

From-SVN: r268175

gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Warray-bounds-2.c
gcc/testsuite/c-c++-common/Warray-bounds-3.c
gcc/testsuite/c-c++-common/Wrestrict-2.c
gcc/testsuite/c-c++-common/Wrestrict.c

index 17fad73ab6ca2b316c9708f316c1d1b66b29e74e..3361da85991c0ae95675449f9be4dd5489908c31 100644 (file)
@@ -1,21 +1,30 @@
+2019-01-22  Martin Sebor  <msebor@redhat.com>
+
+       * c-c++-common/Warray-bounds-2.c: Include headers only if they exist.
+       * c-c++-common/Warray-bounds-3.c: Make xfails conditional on target
+       non_strict_align.
+       * c-c++-common/Wrestrict-2.c: Include headers only if they exist.
+       * c-c++-common/Wrestrict.c: Make xfails conditional on target
+       non_strict_align.
+
 2018-01-22  Steve Ellcey  <sellcey@marvell.com>
 
-       c-c++-common/gomp/pr60823-1.c: Change aarch64-*-* target
+       c-c++-common/gomp/pr60823-1.c: Change aarch64-*-* target
        to aarch64*-*-* target.
-       c-c++-common/gomp/pr60823-3.c: Ditto.
-       g++.dg/gomp/declare-simd-1.C: Ditto.
-       g++.dg/gomp/declare-simd-3.C: Ditto.
-       g++.dg/gomp/declare-simd-4.C: Ditto.
-       g++.dg/gomp/declare-simd-7.C: Ditto.
-       g++.dg/gomp/pr88182.C: Ditto.
-       gcc.dg/gomp/declare-simd-1.c: Ditto.
-       gcc.dg/gomp/declare-simd-3.c: Ditto.
-       gcc.dg/gomp/pr59669-2.c: Ditto.
-       gcc.dg/gomp/pr87895-1.c: Ditto.
-       gcc.dg/gomp/simd-clones-2.c: Ditto.
-       gfortran.dg/gomp/declare-simd-2.f90: Ditto.
-       gfortran.dg/gomp/pr79154-1.f90: Ditto.
-       gfortran.dg/gomp/pr83977.f90: Ditto.
+       c-c++-common/gomp/pr60823-3.c: Ditto.
+       g++.dg/gomp/declare-simd-1.C: Ditto.
+       g++.dg/gomp/declare-simd-3.C: Ditto.
+       g++.dg/gomp/declare-simd-4.C: Ditto.
+       g++.dg/gomp/declare-simd-7.C: Ditto.
+       g++.dg/gomp/pr88182.C: Ditto.
+       gcc.dg/gomp/declare-simd-1.c: Ditto.
+       gcc.dg/gomp/declare-simd-3.c: Ditto.
+       gcc.dg/gomp/pr59669-2.c: Ditto.
+       gcc.dg/gomp/pr87895-1.c: Ditto.
+       gcc.dg/gomp/simd-clones-2.c: Ditto.
+       gfortran.dg/gomp/declare-simd-2.f90: Ditto.
+       gfortran.dg/gomp/pr79154-1.f90: Ditto.
+       gfortran.dg/gomp/pr83977.f90: Ditto.
 
 2019-01-22  Jakub Jelinek  <jakub@redhat.com>
 
index aee35617bacf8ac3a7b6b822c77cae9d95817939..ca2d1c98218ed1a5ac42ba220d90f3b1e308ed5e 100644 (file)
@@ -8,12 +8,27 @@
    { dg-do compile }
    { dg-options "-O2 -Warray-bounds -Wno-stringop-overflow" } */
 
-#include <stddef.h>
-#include <string.h>
+#if __has_include (<stddef.h>)
+#  include <stddef.h>
+#else
+/* For cross-compilers.  */
+typedef __PTRDIFF_TYPE__   ptrdiff_t;
+typedef __SIZE_TYPE__      size_t;
+#endif
+
+#if __has_include (<string.h>)
+#  include <string.h>
+#  undef memcpy
+#  undef strcat
+#  undef strcpy
+#  undef strncpy
+#else
+extern void* memcpy (void*, const void*, size_t);
+extern char* strcat (char*, const char*);
+extern char* strcpy (char*, const char*);
+extern char* strncpy (char*, const char*, size_t);
+#endif
 
-#undef memcpy
-#undef strcpy
-#undef strncpy
 
 #define MAX  (__SIZE_MAX__ / 2)
 
index e49d44ad41db102e835f199570e086deaad7eaff..7f2b33b404a6b041662d4e5032296df9fff77aa3 100644 (file)
@@ -158,7 +158,7 @@ void test_memcpy_overflow (char *d, const char *s, size_t n)
      but known access size is detected.  This works except with small
      sizes that are powers of 2 due to bug .  */
   T (char, 1, arr + SR (DIFF_MAX - 1, DIFF_MAX), s, 1);
-  T (char, 1, arr + SR (DIFF_MAX - 1, DIFF_MAX), s, 2);  /* { dg-warning "pointer overflow between offset \\\[\[0-9\]+, \[0-9\]+] and size 2 accessing array " "bug " { xfail *-*-* } } */
+  T (char, 1, arr + SR (DIFF_MAX - 1, DIFF_MAX), s, 2);  /* { dg-warning "pointer overflow between offset \\\[\[0-9\]+, \[0-9\]+] and size 2 accessing array " "bug " { xfail non_strict_align } } */
   T (char, 1, arr + SR (DIFF_MAX - 2, DIFF_MAX), s, 3);  /* { dg-warning "pointer overflow between offset \\\[\[0-9\]+, \[0-9\]+] and size 3 accessing array " "memcpy" } */
   T (char, 1, arr + SR (DIFF_MAX - 4, DIFF_MAX), s, 5);  /* { dg-warning "pointer overflow between offset \\\[\[0-9\]+, \[0-9\]+] and size 5 accessing array " "memcpy" } */
 }
index c3e9ac82d6412ec8e68b2effd834e937ed7b3d0e..4d901670519f58c1441c8e72063650acc05b8560 100644 (file)
@@ -8,7 +8,29 @@
    { dg-do compile }
    { dg-options "-O2 -Wrestrict" } */
 
-#include <string.h>
+#if __has_include (<stddef.h>)
+#  include <stddef.h>
+#else
+/* For cross-compilers.  */
+typedef __PTRDIFF_TYPE__   ptrdiff_t;
+typedef __SIZE_TYPE__      size_t;
+#endif
+
+#if __has_include (<string.h>)
+#  include <string.h>
+#  undef memcpy
+#  undef strcat
+#  undef strcpy
+#  undef strncat
+#  undef strncpy
+#else
+extern void* memcpy (void*, const void*, size_t);
+extern char* strcat (char*, const char*);
+extern char* strcpy (char*, const char*);
+extern char* strncat (char*, const char*, size_t);
+extern char* strncpy (char*, const char*, size_t);
+#endif
+
 
 static void wrap_memcpy (void *d, const void *s, size_t n)
 {
index d0e3c3411fea593613e45e3db3e81e0467864273..c852b06bbd77fd78368cdca1f69838438c18bd6d 100644 (file)
@@ -53,8 +53,11 @@ void test_memcpy_cst (void *d, const void *s)
 
   T (a, a, 0);
 
-  /* This isn't detected because memcpy calls with small power-of-2 sizes
-     are intentionally folded into safe copies equivalent to memmove.
+  /* This isn't detected because memcpy calls with size of 1 are
+     intentionally folded into safe copies equivalent to memmove,
+     regardless of the target (larger power-of-2 copies may or
+     may not be folded depending on the target -- see non_strict_align
+     below, for example).
      It's marked xfail only because there is value in detecting such
      invalid calls for portability, and as a reminder of why it isn't
      diagnosed.  */
@@ -192,19 +195,19 @@ void test_memcpy_range (char *d, size_t sz)
   T (a + ir, a, 2);
   T (a + ir, a, 3);
   /* The following fails because the size is a small power of 2.  */
-  T (a + ir, a, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps between 1 and 2 bytes at offset \\\[3, 2]" "memcpy" { xfail *-*-*} } */
+  T (a + ir, a, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps between 1 and 2 bytes at offset \(\\\[3, 2]|\\\[2, 3]\)" "pr79220" { xfail non_strict_align } } */
   T (a + ir, a, 5);               /* { dg-warning "accessing 5 bytes at offsets \\\[2, 3] and 0 overlaps between 2 and 3 bytes at offset \\\[2, 3]" "memcpy" } */
 
   T (d + ir, d, 0);
   T (d + ir, d, 1);
   T (d + ir, d, 2);
   T (d + ir, d, 3);
-  T (d + ir, d, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps 1 byte at offset 3" "bug 79220" { xfail *-*-* } } */
+  T (d + ir, d, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps between 1 and 2 bytes at offset \\\[2, 3]" "pr79220" { xfail non_strict_align } } */
   T (d + ir, d, 5);               /* { dg-warning "accessing 5 bytes at offsets \\\[2, 3] and 0 overlaps between 2 and 3 bytes at offset \\\[2, 3]" "memcpy" } */
 
   /* Because the size is constant and a power of 2 the following is
      folded too early to detect the overlap.  */
-  T (d + ir, d, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps 2 byte at offset 2" "memcpy" { xfail *-*-* } } */
+  T (d + ir, d, 4);               /* { dg-warning "accessing 4 bytes at offsets \\\[2, 3] and 0 overlaps between 1 and 2 bytes at offset \\\[2, 3]" "pr79220" { xfail non_strict_align } } */
   T (d + ir, d, 5);               /* { dg-warning "accessing 5 bytes at offsets \\\[2, 3] and 0 overlaps between 2 and 3 bytes at offset \\\[2, 3]" "memcpy" } */
 
   /* Exercise the full range of size_t.  */
This page took 0.079639 seconds and 5 git commands to generate.