summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.jason/net2.C
blob: ffb52d2b7f3841e31d813c75ef807ec1459ac196 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// { dg-do run  }
// Test of various ?: problems.

class D
{
public:
  void a();
  void b();
  D(int i):x(i) {}
private:
  int x;
};

void D::a() {++x;}
void D::b() {--x;}

  
int aa=1, bb=0;

int fa() {return 0;}
int fb() {return 2;}

int main(int argc, char* argv[])
{
  typedef int* pi;
  int* p = (argc == 1)? &aa: &bb;
  *p = 0;

  typedef int (*ifptr)();
  ifptr fp = (argc == 1)? fa: fb;
  aa = fp();
  
  D d(0);
  typedef void (D::*dmem)();
  dmem mfp = (argc == 1)? &D::a: &D::b;
  (d.*mfp)();
  return 0;
}