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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include <stdio.h>
class Map {
class Iter {
public:
int value () { // object type inaccessible for main()
printf ("inaccessible target object type\n");
}
};
friend class MapIter;
};
class MapIter {
typedef Map::Iter Item;
friend Item friendFunc();
public:
Item prev () { // result type inaccessible for main()
printf ("inaccessible result type\n");
return Item ();
}
static void check (const Map::Iter &) {}
};
MapIter::Item friendFunc () {
printf ("inaccessible result, no object type\n");
}
class Outer {
class C {};
class D : public C {};
friend int main();
friend C& func(C);
};
Outer::C& func(Outer::C) {}
void func(int) {}
int main() {
printf ("RightlessCalls: Calls using inaccesible types\n");
printf ("=============================================================\n");
MapIter i;
i.prev ().value ();
// MapIter::check (i.prev ());
friendFunc ();
// TODO: inaccesible argument types are not supported yet!
// printf ("-------------------------------------------------------------\n");
// func (Outer::D()); // here type deduction is tricky
printf ("=============================================================\n");
}
aspect Trace {
advice call("% Map%::...::%(...)" || "% friendFunc()") : before () {
printf ("calling %s: ", JoinPoint::signature ());
}
};
|