summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/testparse.d
blob: 99378a9df53e5df57fd661e0d5635247004c5d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// PERMUTE_ARGS:
// REQUIRED_ARGS: -o-

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=6719

static assert(__traits(compiles, mixin("(const(A))[0..0]")) == false);

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=9232

struct Foo9232
{
    void bar(T)() {}
    void baz() {}
}

void test9232()
{
    Foo9232 foo;
    (foo).bar!int();   // OK <- Error: found '!' when expecting ';' following statement
    ((foo)).bar!int(); // OK
    foo.bar!int();     // OK
    (foo).baz();       // OK
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=9401

struct S9401a
{
    ~this() nothrow pure @safe { }
}

struct S9401b
{
    @safe ~this() pure nothrow { }
}

void test9401() nothrow pure @safe
{
    S9401a s1;
    S9401b s2;
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=9649

class Outer9649
{
    class Inner
    {
    }
}

void test9649()
{
    Outer9649 outer9649;
    (outer9649).new Inner();
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=9679

void test9679(inout int = 0)
{
    if (        auto n = 1) { static assert(is(typeof(n) ==              int)); }
    if (       const n = 1) { static assert(is(typeof(n) ==        const int)); }
    if (   immutable n = 1) { static assert(is(typeof(n) ==    immutable int)); }
    if (shared       n = 1) { static assert(is(typeof(n) == shared       int)); }
    if (shared const n = 1) { static assert(is(typeof(n) == shared const int)); }
    if (       inout n = 1) { static assert(is(typeof(n) ==        inout int)); }
    if (shared inout n = 1) { static assert(is(typeof(n) == shared inout int)); }

    if (       const int n = 1) { static assert(is(typeof(n) ==        const int)); }
    if (   immutable int n = 1) { static assert(is(typeof(n) ==    immutable int)); }
    if (shared       int n = 1) { static assert(is(typeof(n) == shared       int)); }
    if (shared const int n = 1) { static assert(is(typeof(n) == shared const int)); }
    if (       inout int n = 1) { static assert(is(typeof(n) ==        inout int)); }
    if (shared inout int n = 1) { static assert(is(typeof(n) == shared inout int)); }

    if (       const(int) n = 1) { static assert(is(typeof(n) ==        const int)); }
    if (   immutable(int) n = 1) { static assert(is(typeof(n) ==    immutable int)); }
    if (shared      (int) n = 1) { static assert(is(typeof(n) == shared       int)); }
    if (shared const(int) n = 1) { static assert(is(typeof(n) == shared const int)); }
    if (       inout(int) n = 1) { static assert(is(typeof(n) ==        inout int)); }
    if (shared inout(int) n = 1) { static assert(is(typeof(n) == shared inout int)); }

    if (immutable(int)[] n = [1]) { static assert(is(typeof(n) == immutable(int)[])); }
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=9901

template isGood9901(T)
{
    enum isGood9901 = true;
}
void test9901()
{
    string foo(R)(R data) if (isGood9901!R)
    {
        return "";
    }
    foo(1);
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=10199

void test10199()
{
    goto label;
label:
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=12460

void f12460(T)()
{
    static if (is(T == int))
    {
        goto end;
    }
end:
}

void test12460()
{
    f12460!int();
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=11689

void test11689()
{
    deprecated void foo() {}
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=11751

static assert(is(float == typeof(0x0.1p1F)));

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=11957

extern(C++) class C11957
{
    void x() {}
}

void test11957()
{
    extern(C++) class D : C11957
    {
        override void x() {}
    }
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=13049

enum mangle13049(T) = T.mangleof;
alias FP13049 = void function(scope int);                                       // OK
static assert(mangle13049!FP13049 == mangle13049!(void function(scope int)));   // OK <- NG

/***************************************************/
// was not covered until the **12th of March 2019**
void testIfConditionWithSTCandType()
{
    auto call(){return 0;}
    if (const size_t i = call()) {}
}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=20791
extern(C++, "foo", )
struct S {}

/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=22019
void test22019()
{
    final switch (1)
    {
        case 1,:
        case 2,3,:
            break;
    }
}