source: tests/nested-types.cfa @ 10b5970

Last change on this file since 10b5970 was 2853d6f, checked in by Michael Brooks <mlbrooks@…>, 3 weeks ago

Remove uses of warnings to show test success. Eliminate simple causes of other warnings from affected tests and remove the result from WFLAG_OPT_LAX.

Many affected tests also formerly used -fsyntax-only to avoid errors at later compilation stages, or at runtime. Repair such tests to actually work though runtime, and remove them from SYNTAX_ONLY_CODE.

Group tests listed under WFLAGS_OPT according to why they should receive lax treatment. Add reason WFLGAS_OPT_LAX_EXPECT_WARN and give the original list reason WFLGAS_OPT_LAX_TO_INVESTIGATE.

Tests whose purpose is to show a warning are listed as both SYNTAX_ONLY_CODE (so that the warning is the output) and WFLGAS_OPT_LAX_EXPECT_WARN (to document this fact).

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[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
[53692b3]12// Last Modified On : Sat Jun  5 10:07:42 2021
13// Update Count     : 7
[49e1275]14//
15
16typedef int N;
17struct A {
[fd54fef]18        forall(T)
[66812dd]19        struct N {
20                T x;
21        };
[49e1275]22};
23
24struct 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
[2853d6f]66#pragma GCC diagnostic ignored "-Wunused-variable"
67
[49e1275]68int main() {
[66812dd]69        // access nested struct
70        S.T x;
[49e1275]71
[66812dd]72        {
73                struct S {
74                  int i;
75                  struct Z {
76                    double d;
77                  };
78                };
[49e1275]79
[66812dd]80                S.Z z;                                                                                  // gets local S
81                .S.T y;                                                                                 // lookup at global scope only
[49e1275]82
[66812dd]83                const volatile .S.T q;
[49e1275]84#if ERR1
[66812dd]85                T err1;                                                                                 // error: no T in scope
[49e1275]86#endif
87#if ERR2
[66812dd]88                .Z err2;                                                                                // error: no Z in global scope
89                .S.Baz.Bar err3;                                                                // error: .S.Baz => int, int is not aggregate and should not appear left of the dot
90                .S.Z err4;                                                                              // error: no Z in global S
[49e1275]91#endif
[66812dd]92        }
[49e1275]93
[66812dd]94        // U.S un;
[49e1275]95
[66812dd]96        S.Bar y;
[2853d6f]97        S.Baz w;
[66812dd]98        S.T.Bar z;
[49e1275]99
[66812dd]100        // A.N(int) x;  // xxx - should not be an error, but currently is.
101
[2853d6f]102        printf("done\n");
[49e1275]103}
104
105// Local Variables: //
106// tab-width: 4 //
[dc8511c]107// compile-command: "cfa nested-types.cfa" //
[49e1275]108// End: //
Note: See TracBrowser for help on using the repository browser.