summaryrefslogtreecommitdiff
path: root/malloc/tst-mcheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/tst-mcheck.c')
-rw-r--r--malloc/tst-mcheck.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/malloc/tst-mcheck.c b/malloc/tst-mcheck.c
index 296cc473e8..18b0d59bd9 100644
--- a/malloc/tst-mcheck.c
+++ b/malloc/tst-mcheck.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2005-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
@@ -19,6 +19,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <libc-diag.h>
static int errors = 0;
@@ -36,7 +37,14 @@ do_test (void)
errno = 0;
+ 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 = malloc (-1);
+ DIAG_POP_NEEDS_COMMENT;
if (p != NULL)
merror ("malloc (-1) succeeded.");
@@ -67,10 +75,17 @@ do_test (void)
if (p == NULL)
merror ("malloc (512) failed.");
+ 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
if (realloc (p, -256) != NULL)
merror ("realloc (p, -256) succeeded.");
else if (errno != ENOMEM)
merror ("errno is not set correctly.");
+ DIAG_POP_NEEDS_COMMENT;
free (p);
@@ -78,10 +93,17 @@ do_test (void)
if (p == NULL)
merror ("malloc (512) failed.");
+ 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
if (realloc (p, -1) != NULL)
merror ("realloc (p, -1) succeeded.");
else if (errno != ENOMEM)
merror ("errno is not set correctly.");
+ DIAG_POP_NEEDS_COMMENT;
free (p);
free (q);