summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/opt/ptrmem3.C
blob: 552a92c9c1a7406617785cfc0be7959f537b6cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// { dg-options "-O1" }

#include <stdio.h>
struct A {
     A(int arg) : ia(arg) {}
     int x,y,z,ia;
     int mf(int arg) { return arg + ia; }
};
int func(int A::*pdm, int (A::*pmf)(int)) //      2.      regular function
{ 
     A oa(2);
     return ((&oa)->*pdm) + (oa.*pmf)(2); 
}       
int main()
{
     int val;

     int A::*pda = &A::ia;           
     int (A::*pmfa)(int) = &A::mf;   
     val = func( pda, pmfa );
     if(val != 6)
       printf("val=%d, expect 6 \n", val);
}