File: main.cc

package info (click to toggle)
aspectc%2B%2B 1%3A2.3%2Bgit20221129-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,988 kB
  • sloc: cpp: 109,125; ansic: 7,644; sh: 2,262; makefile: 1,312; pascal: 634; python: 402; xml: 349
file content (55 lines) | stat: -rw-r--r-- 1,355 bytes parent folder | download | duplicates (8)
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 ());
  }
};