source:
tests/nested-types.cfa
@
a12810d
Last change on this file since a12810d was 66812dd, checked in by , 4 years ago | |
---|---|
|
|
File size: 1.8 KB |
Rev | Line | |
---|---|---|
[49e1275] | 1 | // |
2 | // Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo | |
3 | // | |
4 | // The contents of this file are covered under the licence agreement in the | |
5 | // file "LICENCE" distributed with Cforall. | |
6 | // | |
[dc8511c] | 7 | // nested-types.cfa -- |
[49e1275] | 8 | // |
9 | // Author : Rob Schluntz | |
10 | // Created On : Mon Jul 9 10:20:03 2018 | |
[dc8511c] | 11 | // Last Modified By : Peter A. Buhr |
[66812dd] | 12 | // Last Modified On : Sun Sep 27 08:48:59 2020 |
13 | // Update Count : 6 | |
[49e1275] | 14 | // |
15 | ||
16 | typedef int N; | |
17 | struct A { | |
[66812dd] | 18 | forall(otype T) |
19 | struct N { | |
20 | T x; | |
21 | }; | |
[49e1275] | 22 | }; |
23 | ||
24 | struct S { | |
[66812dd] | 25 | struct T { |
26 | int i; | |
27 | typedef int Bar; | |
28 | }; | |
29 | T x; | |
30 | ||
31 | // struct U; | |
32 | typedef T Bar; | |
33 | typedef int Baz; | |
[49e1275] | 34 | }; |
35 | ||
36 | // // // // need a way to stuff a qualified name into a struct decl | |
37 | // // struct S.U { | |
38 | // // double z; | |
39 | // // }; | |
40 | ||
41 | // // what will this do? | |
42 | // struct U { | |
43 | // union S { | |
44 | // int i; | |
45 | // double d; | |
46 | // }; | |
47 | // }; | |
48 | ||
49 | // struct T { | |
50 | // double d; | |
51 | // }; | |
52 | ||
[6988dc6] | 53 | // struct S { |
54 | // enum C { R, G, B }; | |
55 | // int i; | |
56 | // struct T { | |
57 | // int i; | |
58 | // }; | |
59 | // T t; | |
60 | // }; | |
61 | ||
62 | // S s; | |
63 | // S.C c; | |
64 | // S.T t; | |
65 | ||
[49e1275] | 66 | int main() { |
[66812dd] | 67 | // access nested struct |
68 | S.T x; | |
[49e1275] | 69 | |
[66812dd] | 70 | { |
71 | struct S { | |
72 | int i; | |
73 | struct Z { | |
74 | double d; | |
75 | }; | |
76 | }; | |
[49e1275] | 77 | |
[66812dd] | 78 | S.Z z; // gets local S |
79 | .S.T y; // lookup at global scope only | |
[49e1275] | 80 | |
[66812dd] | 81 | const volatile .S.T q; |
[49e1275] | 82 | #if ERR1 |
[66812dd] | 83 | T err1; // error: no T in scope |
[49e1275] | 84 | #endif |
85 | #if ERR2 | |
[66812dd] | 86 | .Z err2; // error: no Z in global scope |
87 | .S.Baz.Bar err3; // error: .S.Baz => int, int is not aggregate and should not appear left of the dot | |
88 | .S.Z err4; // error: no Z in global S | |
[49e1275] | 89 | #endif |
[66812dd] | 90 | } |
[49e1275] | 91 | |
[66812dd] | 92 | // U.S un; |
[49e1275] | 93 | |
[66812dd] | 94 | S.Bar y; |
95 | S.Baz x; | |
96 | S.T.Bar z; | |
[49e1275] | 97 | |
[66812dd] | 98 | // A.N(int) x; // xxx - should not be an error, but currently is. |
99 | ||
100 | #pragma message( "Compiled" ) // force non-empty .expect file | |
[49e1275] | 101 | } |
102 | ||
103 | // Local Variables: // | |
104 | // tab-width: 4 // | |
[dc8511c] | 105 | // compile-command: "cfa nested-types.cfa" // |
[49e1275] | 106 | // End: // |
Note: See TracBrowser
for help on using the repository browser.