Update copyright year range in all GDB files.
[external/binutils.git] / gdb / testsuite / gdb.dwarf2 / implptr.c
1 /* Copyright (C) 2010-2019 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
24 struct S
25 {
26   int *x, y;
27 };
28
29 int u[6];
30
31 static inline void
32 add (struct S *a, struct S *b, int c)
33 {
34   *a->x += *b->x;               /* baz breakpoint */
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
43 int
44 foo (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
55 typedef int *intp;
56 typedef intp *intpp;
57 typedef intpp *intppp;
58
59 int __attribute__ ((noinline, used, noclone)) 
60 bar (int i) 
61 {
62   intp j = &i;
63   intpp k = &j;
64   intppp l = &k;
65   i++;                          /* bar breakpoint */
66   return i;
67 }
68
69 int main ()
70 {
71   return bar(5) + foo (23);
72 }