No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.cp / member-ptr.cc
blobe668c4623c1b5de913782dc0f1258c0dc47add44
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 1998, 1999, 2004 Free Software Foundation, Inc.
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 2 of the License, or
8 (at your option) any later version.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 extern "C" {
23 #include <stdio.h>
27 class A {
28 public:
29 A();
30 int foo (int x);
31 int bar (int y);
32 virtual int baz (int z);
33 char c;
34 int j;
35 int jj;
36 static int s;
39 class B {
40 public:
41 static int s;
44 int A::s = 10;
45 int B::s = 20;
47 A::A()
49 c = 'x';
50 j = 5;
53 int A::foo (int dummy)
55 j += 3;
56 return j + dummy;
59 int A::bar (int dummy)
61 int r;
62 j += 13;
63 r = this->foo(15);
64 return r + j + 2 * dummy;
67 int A::baz (int dummy)
69 int r;
70 j += 15;
71 r = this->foo(15);
72 return r + j + 12 * dummy;
75 int fum (int dummy)
77 return 2 + 13 * dummy;
80 typedef int (A::*PMF)(int);
82 typedef int A::*PMI;
84 int main ()
86 A a;
87 A * a_p;
88 PMF pmf;
90 PMF * pmf_p;
91 PMI pmi;
93 a.j = 121;
94 a.jj = 1331;
96 int k;
98 a_p = &a;
100 pmi = &A::j;
101 pmf = &A::bar;
102 pmf_p = &pmf;
104 pmi = NULL;
106 k = (a.*pmf)(3);
108 pmi = &A::jj;
109 pmf = &A::foo;
110 pmf_p = &pmf;
112 k = (a.*pmf)(4);
114 k = (a.**pmf_p)(5);
116 k = a.*pmi;
119 k = a.bar(2);
121 k += fum (4);
123 B b;
125 k += b.s;