Make test cases executable

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6166 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-05-13 19:50:01 +00:00
parent 5bd1acc0d6
commit 1f1f371d12
2 changed files with 32 additions and 5 deletions

View File

@ -1,5 +1,17 @@
#include <stdio.h>
struct B { int i, j; };
struct D : public B {};
int D::*di = &D::i;
int D::*dj = &D::j;
int main() {
D d;
d.i = d.j = 0;
d.*di = 4;
d.*dj = 7;
printf("%d %d\n", d.i, d.j);
return 0;
}

View File

@ -1,8 +1,23 @@
struct B { int i(); int j(); };
#include <stdio.h>
void foo(int (B::*Fn)());
struct B {
int X;
void i() {
printf("i, %d\n", X);
}
void j() {
printf("j, %d\n", X);
}
};
void test() {
foo(&B::i);
foo(&B::j);
void foo(int V, void (B::*Fn)()) {
B b; b.X = V;
(b.*Fn)();
}
int main() {
foo(4, &B::i);
foo(6, &B::j);
foo(-1, &B::i);
return 0;
}