Commit | Line | Data |
---|---|---|
29c1c244 WT |
1 | /* Test program for MPX map allocated bounds. |
2 | ||
88b9d363 | 3 | Copyright 2015-2022 Free Software Foundation, Inc. |
29c1c244 WT |
4 | |
5 | Contributed by Intel Corp. <walfred.tedeschi@intel.com> | |
6 | <mircea.gherzan@intel.com> | |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 3 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
22 | ||
23 | #include <stdlib.h> | |
29c1c244 WT |
24 | #define SIZE 5 |
25 | ||
26 | typedef int T; | |
27 | ||
29c1c244 WT |
28 | void |
29 | foo (T *p) | |
30 | { | |
31 | T *x; | |
32 | ||
33 | #if defined __GNUC__ && !defined __INTEL_COMPILER | |
34 | __bnd_store_ptr_bounds (p, &p); | |
35 | #endif | |
36 | ||
37 | x = p + SIZE - 1; | |
38 | ||
39 | #if defined __GNUC__ && !defined __INTEL_COMPILER | |
40 | __bnd_store_ptr_bounds (x, &x); | |
41 | #endif | |
14cb1c0b WT |
42 | /* Dummy assign. */ |
43 | x = x + 1; /* after-assign */ | |
44 | return; | |
29c1c244 WT |
45 | } |
46 | ||
47 | int | |
48 | main (void) | |
49 | { | |
3f94e588 | 50 | T *a = NULL; |
29c1c244 | 51 | |
3f94e588 | 52 | a = calloc (SIZE, sizeof (T)); /* after-decl */ |
29c1c244 | 53 | #if defined __GNUC__ && !defined __INTEL_COMPILER |
3f94e588 | 54 | __bnd_store_ptr_bounds (a, &a); |
29c1c244 WT |
55 | #endif |
56 | ||
3f94e588 TV |
57 | foo (a); /* after-alloc */ |
58 | free (a); | |
59 | ||
29c1c244 WT |
60 | return 0; |
61 | } |