summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/json.d
blob: f4d68e7dc8c6ef13bbeb3ad2c90924012c878926 (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// PERMUTE_ARGS:
// REQUIRED_ARGS: -d -preview=dip1000 -o- -X -Xf-
// EXTRA_FILES: imports/jsonimport1.d imports/jsonimport2.d imports/jsonimport3.d imports/jsonimport4.d
// TRANSFORM_OUTPUT: sanitize_json
// TEST_OUTPUT_FILE: extra-files/json.json
module json;

shared static this() {}
static this() {}
shared static ~this() {}
static ~this() {}

template X(T)
{
    shared static this() {}
    static this() {}
    shared static ~this() {}
    static ~this() {}
}

alias SSCDX = X!int;

class SSCDClass
{
    shared static this() {}
    static this() {}
    shared static ~this() {}
    static ~this() {}
}

#line 17

alias int myInt;
myInt x; // https://issues.dlang.org/show_bug.cgi?id=3404

struct Foo(T) { T t; }
class  Bar(int T) { int t = T; }
interface Baz(T...) { T[0] t() const; } // https://issues.dlang.org/show_bug.cgi?id=3466

template P(alias T) {}

class Bar2 : Bar!1, Baz!(int, 2, null) {
    this() {}
    ~this() {} // https://issues.dlang.org/show_bug.cgi?id=4178

    static foo() {}
    protected abstract Foo!int baz();
    override int t() const { return 0; }
}

class Bar3 : Bar2 {
    private int val;
    this(int i) { val = i; }

    protected override Foo!int baz() { return Foo!int(val); }
}

struct Foo2 {
    Bar2 bar2;
    union U {
        struct {
            short s;
            int i;
        }
        Object o;
    }
}

struct Foo3(bool b) {
    version(D_Ddoc) {
        /// Doc 1
        void method1();
    }
    static if (b) {
        /// Doc 2
        void method2();
    } else {
        /// Doc 3
        void method3();
    }

    /// Doc 4
    void method4();
}

/++
 + Documentation test
 +/
@trusted myInt bar(ref uint blah, Bar2 foo = new Bar3(7)) // https://issues.dlang.org/show_bug.cgi?id=4477
{
    return -1;
}

@property int outer() nothrow
in {
    assert(true);
}
out(result) {
    assert(result == 18);
}
do {
    int x = 8;
    int inner(void* v) nothrow
    {
        int y = 2;
        assert(true);
        return x + y;
    }
    int z = inner(null);
    return x + z;
}

/** Issue 9484 - selective and renamed imports */
import imports.jsonimport1 : target1, target2;
import imports.jsonimport2 : alias1 = target1, alias2 = target2;
import imports.jsonimport3 : alias3 = target1, alias4 = target2, target3;
import imports.jsonimport4;

struct S
{
    /** Issue 9480 - Template name should be stripped of parameters */
    this(T)(T t) { }
}

/** Issue 9755 - Protection not emitted properly for Templates. */
private struct S1_9755(T) { }
package struct S2_9755(T) { }

class C_9755
{
    protected static class CI_9755(T) { }
}

/** Issue 10011 - init property is wrong for object initializer. */
const Object c_10011 = new Object();

///
enum Numbers
{
    unspecified1,
    one  = 2,
    two  = 3,
    FILE_NOT_FOUND = 101,
    unspecified3,
    unspecified4,
    four = 4,
}

template IncludeConstraint(T) if (T == string) {}

static foreach(enum i; 0..3)
{
    mixin("int a" ~ i.stringof ~ " = 1;");
}

alias Seq(T...) = T;

static foreach(int i, alias a; Seq!(a0, a1, a2))
{
	mixin("alias b" ~ i.stringof ~ " = a;");
}

// return ref, return scope, return ref scope
ref int foo(return ref int a) @safe
{
	return a;
}

int* foo(return scope int* a) @safe
{
	return a;
}

ref int* foo(scope return ref int* a) @safe
{
	return a;
}

struct SafeS
{
@safe:
    ref SafeS foo() return
    {
        return this;
    }

    SafeS foo2() return scope
    {
        return this;
    }

    ref SafeS foo3() return scope
    {
        static SafeS s; return s;
    }

	int* p;
}

extern int vlinkageDefault;
extern(D) int vlinkageD;
extern(C) int vlinakgeC;
extern(C++) __gshared int vlinkageCpp;
extern(Windows) int vlinkageWindows;
extern(Objective-C) int vlinkageObjc;
extern(System) int vlinkageSystem;
extern int flinkageDefault();
extern(D) int flinkageD();
extern(C) int linakgeC();
extern(C++) int flinkageCpp();
extern(Windows) int flinkageWindows();
extern(Objective-C) int flinkageObjc();
extern(System) int flinkageSystem();
mixin template test18211(int n)
{
    static foreach (i; 0 .. n>10 ? 10 : n)
    {
        mixin("enum x" ~ cast(char)('0' + i));
    }
    static if (true) {}
}

alias F = size_t function (size_t a);