source: src/tests/completeTypeError.c @ 2c57025

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 2c57025 was 2c57025, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

add support for built-in sized trait which decouples size/alignment information from otype parameters, add test for sized trait

  • Property mode set to 100644
File size: 631 bytes
Line 
1void foo(int *) {}
2void bar(void *) {}
3forall(otype T) void baz(T *);
4forall(dtype T) void qux(T *);
5forall(dtype T | sized(T)) void quux(T *);
6
7int main() {
8        int *i;
9        void *v;
10
11        // okay
12        foo(i);
13        bar(i);
14        baz(i);
15        qux(i);
16        quux(i);
17
18        bar(v);
19        qux(v);
20        foo(v); // questionable, but works at the moment for C compatibility
21
22        // bad
23        baz(v);
24        quux(v);
25}
26
27forall(otype T)
28void baz(T * x) {
29        // okay
30        bar(x);
31        baz(x);
32        qux(x);
33        quux(x);
34}
35
36forall(dtype T)
37void qux(T * y) {
38        // okay
39        bar(y);
40        qux(y);
41
42        // bad
43        baz(y);
44        quux(y);
45}
46
47forall(dtype T | sized(T))
48void qux(T * z) {
49        // okay
50        bar(z);
51        qux(z);
52        quux(z);
53
54        // bad
55        baz(z);
56}
57
Note: See TracBrowser for help on using the repository browser.