about summary refs log tree commit diff
path: root/malloc/tst-realloc.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-01-04 23:32:14 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-01-04 23:32:14 +0000
commit3d7229c2507be1daf0c3e15e1f134076fa8b9025 (patch)
tree301ca636f6bede4f41440b3aab519dbb6ec807e0 /malloc/tst-realloc.c
parent179b86750caeb0a0a4798830d6d52a00dc70db2d (diff)
downloadglibc-3d7229c2507be1daf0c3e15e1f134076fa8b9025.tar.gz
glibc-3d7229c2507be1daf0c3e15e1f134076fa8b9025.tar.xz
glibc-3d7229c2507be1daf0c3e15e1f134076fa8b9025.zip
Fix malloc/ tests for GCC 7 -Walloc-size-larger-than=.
GCC 7 has a -Walloc-size-larger-than= warning for allocations of half
the address space or more.  This causes errors building glibc tests
that deliberately test failure of very large allocations.  This patch
arranges for this warning to be ignored around the problematic
function calls.

Tested compilation for aarch64 (GCC mainline) with
build-many-glibcs.py; did execution testing for x86_64 (GCC 5).

	* malloc/tst-malloc.c: Include <libc-internal.h>.
	(do_test): Disable -Walloc-size-larger-than= around tests of
	malloc with negative sizes.
	* malloc/tst-mcheck.c: Include <libc-internal.h>.
	(do_test): Disable -Walloc-size-larger-than= around tests of
	malloc and realloc with negative sizes.
	* malloc/tst-realloc.c: Include <libc-internal.h>.
	(do_test): Disable -Walloc-size-larger-than= around tests of
	realloc with negative sizes.
Diffstat (limited to 'malloc/tst-realloc.c')
-rw-r--r--malloc/tst-realloc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c
index 53182b35c6..7f1f228c06 100644
--- a/malloc/tst-realloc.c
+++ b/malloc/tst-realloc.c
@@ -19,6 +19,7 @@
 #include <malloc.h>
 #include <stdio.h>
 #include <string.h>
+#include <libc-internal.h>
 
 static int errors = 0;
 
@@ -39,7 +40,14 @@ do_test (void)
   errno = 0;
 
   /* realloc (NULL, ...) behaves similarly to malloc (C89).  */
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  /* GCC 7 warns about too-large allocations; here we want to test
+     that they fail.  */
+  DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
+#endif
   p = realloc (NULL, -1);
+  DIAG_POP_NEEDS_COMMENT;
   save = errno;
 
   if (p != NULL)
@@ -111,7 +119,14 @@ do_test (void)
     merror ("first 16 bytes were not correct");
 
   /* Check failed realloc leaves original untouched (C89).  */
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  /* GCC 7 warns about too-large allocations; here we want to test
+     that they fail.  */
+  DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
+#endif
   c = realloc (p, -1);
+  DIAG_POP_NEEDS_COMMENT;
   if (c != NULL)
     merror ("realloc (p, -1) succeeded.");