File: main.cc

package info (click to toggle)
aspectc%2B%2B 1.0pre4~svn.20080711-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 104,504 kB
  • ctags: 363,975
  • sloc: cpp: 1,645,814; ansic: 16,601; sh: 2,175; makefile: 1,043
file content (65 lines) | stat: -rw-r--r-- 1,144 bytes parent folder | download | duplicates (5)
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
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <string.h>

struct S {
	int i;
	int j;
	S () {}
	void g () const {}
};

void f1 (S a[1]) {}
void f2 (S *a) {}
void f3 (S (&a)[2]) {}

class C {
public:
  S a[2];
  char b[10];
  union {
    short shortVal;
    int intVal;
    char* stringVal;
  };
  union {
    int blibs;
    double blubs;
  };
  char *str () const { return (char*)b; }
};

aspect TestCopyConstructorGeneration {
  advice construction ("C") : around () {
    printf ("before %s\n", JoinPoint::signature ());
    tjp->proceed ();
    printf ("after %s\n", JoinPoint::signature ());
  }
};

int main () {
  printf ("ArrayWrapper: tests if wrapped arrays behave like arrays\n");
  printf ("========================================================\n");
  const C cc;
  C c (cc);
  cc.a[0];
  &cc.a[0];
  c.a[0];
  &c.a[0];
  const S *p = 0;
  p = &c.a[1l];
  c.a[1] = c.a[0];
  c.a[0] = cc.a[0];
  c.a[0].g ();
  // error ...
  // cc.a[0] = c.a[0];
  memcpy (c.a, cc.a, sizeof (c.a));
  f1 (c.a);
  f2 (c.a);
  // another error
  // f3 (cc.a);
  f3 (c.a);
  &c.a;
  printf ("========================================================\n");
  return 0;
}