1 /* Copyright (C) 1999-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
21 #include <libc-diag.h>
23 static int errors
= 0;
26 merror (const char *msg
)
29 printf ("Error: %s\n", msg
);
40 DIAG_PUSH_NEEDS_COMMENT
;
41 #if __GNUC_PREREQ (7, 0)
42 /* GCC 7 warns about too-large allocations; here we want to test
44 DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
47 DIAG_POP_NEEDS_COMMENT
;
51 merror ("malloc (-1) succeeded.");
53 if (p
== NULL
&& save
!= ENOMEM
)
54 merror ("errno is not set correctly");
58 merror ("malloc (10) failed.");
60 /* realloc (p, 0) == free (p). */
63 merror ("realloc (p, 0) failed.");
67 merror ("malloc (0) failed.");
71 merror ("realloc (p, 0) failed.");
73 p
= malloc (513 * 1024);
75 merror ("malloc (513K) failed.");
77 DIAG_PUSH_NEEDS_COMMENT
;
78 #if __GNUC_PREREQ (7, 0)
79 /* GCC 7 warns about too-large allocations; here we want to test
81 DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
83 q
= malloc (-512 * 1024);
84 DIAG_POP_NEEDS_COMMENT
;
86 merror ("malloc (-512K) succeeded.");
93 #define TEST_FUNCTION do_test ()
94 #include "../test-skeleton.c"