xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.fortran/mixed-lang-stack.cpp (revision ae87de8892f277bece3527c15b186ebcfa188227)
1 /* Copyright 2020 Free Software Foundation, Inc.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License as published by
5    the Free Software Foundation; either version 2 of the License, or
6    (at your option) any later version.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15 
16 #include <cstring>
17 #include <cstdlib>
18 
19 class base_one
20 {
21   int num1 = 1;
22   int num2 = 2;
23   int num3 = 3;
24 };
25 
26 class base_two
27 {
28 public:
29   base_two ()
30   {
31     string = strdup ("Something in C++");
32   }
33 
34   ~base_two ()
35   {
36     free (string);
37   }
38 
39   char *string = nullptr;
40   float val = 3.5;
41 };
42 
43 class derived_type : public base_one, base_two
44 {
45 public:
46   derived_type ()
47     : base_one (),
48       base_two ()
49   {
50     /* Nothing.  */
51   }
52 
53 private:
54   int xxx = 9;
55   float yyy = 10.5;
56 };
57 
58 static void mixed_func_1f ();
59 static void mixed_func_1g ();
60 
61 extern "C"
62 {
63   /* Entry point to be called from Fortran. */
64   void
65   mixed_func_1e ()
66   {
67     mixed_func_1f ();
68   }
69 
70   /* The entry point back into Fortran.  */
71   extern void mixed_func_1h_ ();
72 }
73 
74 static void
75 mixed_func_1g (derived_type obj)
76 {
77   mixed_func_1h_ ();
78 }
79 
80 static void
81 mixed_func_1f () {
82   derived_type obj;
83 
84   mixed_func_1g (obj);
85 }
86