source: tests/nested-types.cfa @ 0dbecad

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0dbecad was 6988dc6, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

add future testing and adjust expected output

  • Property mode set to 100644
File size: 1.7 KB
Line 
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//
7// nested-types.cfa --
8//
9// Author           : Rob Schluntz
10// Created On       : Mon Jul 9 10:20:03 2018
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Feb 12 18:21:15 2020
13// Update Count     : 3
14//
15
16typedef int N;
17struct A {
18  forall(otype T)
19  struct N {
20    T x;
21  };
22};
23
24struct S {
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;
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
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
66int main() {
67  // access nested struct
68  S.T x;
69
70  {
71    struct S {
72      int i;
73      struct Z {
74        double d;
75      };
76    };
77
78    S.Z z;   // gets local S
79    .S.T y;  // lookup at global scope only
80
81    const volatile .S.T q;
82#if ERR1
83    T err1;           // error: no T in scope
84#endif
85#if ERR2
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
89#endif
90  }
91
92  // U.S un;
93
94  S.Bar y;
95  S.Baz x;
96  S.T.Bar z;
97
98  // A.N(int) x;  // xxx - should not be an error, but currently is.
99}
100
101// Local Variables: //
102// tab-width: 4 //
103// compile-command: "cfa nested-types.cfa" //
104// End: //
Note: See TracBrowser for help on using the repository browser.