source: tests/errors/scope-type.cfa @ 59627b3

Last change on this file since 59627b3 was 4d860ea3, checked in by Michael Brooks <mlbrooks@…>, 13 months ago

Fix compiler bug where duplicate type declarations caused crash.

And add missing test. The test runs and fails with the previous cfa compiler.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1// The type-level analog of errors/scope.
2// Keep harmonized with errors/scope.
3
4#ifdef OMIT_DRIVING_REJECTIONS
5// For manual sanity checking:
6// Leave out the offensive declarations and verify that what's left is accepted.
7#define EXPREJ(...)
8#else
9#define EXPREJ(...) __VA_ARGS__
10#endif
11
12        struct thisIsAnError {};
13EXPREJ( struct thisIsAnError {}; )
14
15        struct thisIsNotAnError {};
16
17        // There's no type-level analog to overloading at one level:
18        //x    float thisIsNotAnError;
19
20        int thisIsAlsoNotAnError() {
21          struct thisIsNotAnError { int xxx; };
22        }
23
24        // There's no type-level analog to overloading at one level, again:
25        //x    int thisIsAlsoNotAnError( double x ) {
26        //x    }
27
28        struct thisIsStillNotAnError;
29        struct thisIsStillNotAnError;
30
31        // Has analog at type level but would be a repeat (no analog of function vs variable):
32        //x
33        //x    double butThisIsAnError( double ) {
34        //x    }
35        //x
36        //x    double butThisIsAnError( double ) {
37        //x    }
38
39
40
41        //
42        // Repeat the validly harmonized cases, across various type forms
43        //
44
45        // union
46
47        union thisIsAnError_u {};
48EXPREJ( union thisIsAnError_u {}; )
49
50        union thisIsNotAnError_u {};
51
52        int thisIsAlsoNotAnError_u() {
53          union thisIsNotAnError_u { int xxx; };
54        }
55
56        union thisIsStillNotAnError_u;
57        union thisIsStillNotAnError_u;
58
59        // enum
60
61        enum thisIsAnError_e { E0 };
62EXPREJ( enum thisIsAnError_e { E0 }; )
63
64        enum thisIsNotAnError_e { E1 };
65
66        int thisIsAlsoNotAnError_e() {
67          enum thisIsNotAnError_e { E1_xxx };
68        }
69
70        enum thisIsStillNotAnError_e;
71        enum thisIsStillNotAnError_e;
72
73        // polymorphic
74
75        forall(T&)  struct thisIsAnError_p {};
76EXPREJ( forall(Tx&) struct thisIsAnError_p {}; )
77
78        forall(T&)  struct thisIsNotAnError_p {};
79
80        int thisIsAlsoNotAnError_p() {
81          forall(Tx&) struct thisIsNotAnError_p { int xxx; };
82        }
83
84        forall(Tx&)
85        int thisIsAlsoNotAnError_p2() {
86          struct thisIsNotAnError_p { Tx * xxx; };
87        }
88
89        forall(T&)  struct thisIsStillNotAnError_p;
90      #ifdef SHOW_TRAC_284
91        forall(Tx&) struct thisIsStillNotAnError_p;  // should be accepted, but blocked
92      #endif
Note: See TracBrowser for help on using the repository browser.