xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.linespec/cp-completion-aliases.cc (revision 15a984a0d95c8f96abe9717ee6241762c55dc106)
1 /* This testcase is part of GDB, the GNU debugger.
2 
3    Copyright 2019-2020 Free Software Foundation, Inc.
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 #include <cstring>
19 
20 template<typename T>
21 struct magic
22 {
23   T x;
24 };
25 
26 struct object
27 {
28   int a;
29 };
30 
31 typedef magic<int> int_magic_t;
32 
33 typedef object *object_p;
34 
35 typedef const char *my_string_t;
36 
37 static int
38 get_value (object_p obj)
39 {
40   return obj->a;
41 }
42 
43 static int
44 get_something (object_p obj)
45 {
46   return obj->a;
47 }
48 
49 static int
50 get_something (my_string_t msg)
51 {
52   return strlen (msg);
53 }
54 
55 static int
56 grab_it (int_magic_t *var)
57 {
58   return var->x;
59 }
60 
61 int
62 main ()
63 {
64   magic<int> m;
65   m.x = 4;
66 
67   object obj;
68   obj.a = 0;
69 
70   int val = (get_value (&obj) + get_something (&obj)
71 	     + get_something ("abc") + grab_it (&m));
72   return val;
73 }
74