]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/implptr.c
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / implptr.c
CommitLineData
8acc9f48 1/* Copyright (C) 2010-2013 Free Software Foundation, Inc.
8cf6f0b1
TT
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{
543305c9 34 *a->x += *b->x; /* baz breakpoint */
8cf6f0b1
TT
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
0e37a63c
JK
55typedef int *intp;
56typedef intp *intpp;
57typedef intpp *intppp;
58
8cf6f0b1
TT
59int __attribute__ ((noinline, used, noclone))
60bar (int i)
61{
0e37a63c
JK
62 intp j = &i;
63 intpp k = &j;
64 intppp l = &k;
8cf6f0b1
TT
65 i++; /* bar breakpoint */
66 return i;
67}
68
69int main ()
70{
71 return bar(5) + foo (23);
72}