ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 8d4f7fe was
f7e749f,
checked in by Rob Schluntz <rschlunt@…>, 8 years ago
|
added tests for polymorphic tuples and cast on tuples, updated a couple of other tests
|
-
Property mode set to
100644
|
File size:
786 bytes
|
Line | |
---|
1 | void foo(int *) {} |
---|
2 | void bar(void *) {} |
---|
3 | forall(otype T) void baz(T *); |
---|
4 | forall(dtype T) void qux(T *); |
---|
5 | forall(dtype T | sized(T)) void quux(T *); |
---|
6 | |
---|
7 | struct A; // incomplete |
---|
8 | struct B {}; // complete |
---|
9 | |
---|
10 | int main() { |
---|
11 | int *i; |
---|
12 | void *v; |
---|
13 | |
---|
14 | // A * x; |
---|
15 | // A * y; |
---|
16 | // B * x; |
---|
17 | // B * z; |
---|
18 | |
---|
19 | // okay |
---|
20 | *i; |
---|
21 | // *x; // picks B |
---|
22 | // *z; |
---|
23 | foo(i); |
---|
24 | bar(i); |
---|
25 | baz(i); |
---|
26 | qux(i); |
---|
27 | quux(i); |
---|
28 | |
---|
29 | bar(v); |
---|
30 | qux(v); |
---|
31 | foo(v); // questionable, but works at the moment for C compatibility |
---|
32 | |
---|
33 | // bad |
---|
34 | *v; |
---|
35 | // *y; |
---|
36 | baz(v); |
---|
37 | quux(v); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | forall(otype T) |
---|
42 | void baz(T * x) { |
---|
43 | // okay |
---|
44 | bar(x); |
---|
45 | baz(x); |
---|
46 | qux(x); |
---|
47 | quux(x); |
---|
48 | *x; |
---|
49 | } |
---|
50 | |
---|
51 | forall(dtype T) |
---|
52 | void qux(T * y) { |
---|
53 | // okay |
---|
54 | bar(y); |
---|
55 | qux(y); |
---|
56 | |
---|
57 | // bad |
---|
58 | baz(y); |
---|
59 | quux(y); |
---|
60 | *y; |
---|
61 | } |
---|
62 | |
---|
63 | forall(dtype T | sized(T)) |
---|
64 | void qux(T * z) { |
---|
65 | // okay |
---|
66 | bar(z); |
---|
67 | qux(z); |
---|
68 | quux(z); |
---|
69 | *z; |
---|
70 | |
---|
71 | // bad |
---|
72 | baz(z); |
---|
73 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.