]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/implptr.c
gdb
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / implptr.c
CommitLineData
8cf6f0b1
TT
1/* Copyright (C) 2010 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* The original program corresponding to implptr.S.
19 This came from Jakub's gcc-patches email implementing
20 DW_OP_GNU_implicit_pointer.
21 Note that it is not ever compiled, implptr.S is used instead.
22 However, it is used to extract breakpoint line numbers. */
23
24struct S
25{
26 int *x, y;
27};
28
29int u[6];
30
31static inline void
32add (struct S *a, struct S *b, int c)
33{
34 *a->x += *b->x;
35 a->y += b->y;
36 u[c + 0]++;
37 a = (struct S *) 0;
38 u[c + 1]++;
39 a = b;
40 u[c + 2]++;
41}
42
43int
44foo (int i)
45{
46 int j = i;
47 struct S p[2] = { {&i, i * 2}, {&j, j * 2} };
48 add (&p[0], &p[1], 0);
49 p[0].x = &j;
50 p[1].x = &i;
51 add (&p[0], &p[1], 3);
52 return i + j; /* foo breakpoint */
53}
54
55int __attribute__ ((noinline, used, noclone))
56bar (int i)
57{
58 int *j = &i;
59 int **k = &j;
60 int ***l = &k;
61 i++; /* bar breakpoint */
62 return i;
63}
64
65int main ()
66{
67 return bar(5) + foo (23);
68}