| 1 |
// REQUIRED_ARGS: -w |
| 2 |
// PERMUTE_ARGS: |
| 3 |
|
| 4 |
extern(C) int printf(const char*, ...); |
| 5 |
|
| 6 |
/******************************************/ |
| 7 |
|
| 8 |
class F { } |
| 9 |
int foo() |
| 10 |
{ |
| 11 |
scope F f = new F(); // comment out and warning goes away |
| 12 |
return 0; |
| 13 |
} |
| 14 |
|
| 15 |
/******************************************/ |
| 16 |
|
| 17 |
int foo2() |
| 18 |
{ |
| 19 |
try |
| 20 |
{ |
| 21 |
return 0; |
| 22 |
} |
| 23 |
finally { } |
| 24 |
} |
| 25 |
|
| 26 |
/******************************************/ |
| 27 |
|
| 28 |
private int getNthInt(A...)(uint index, A args) |
| 29 |
{ |
| 30 |
foreach (i, arg; args) |
| 31 |
{ |
| 32 |
static if (is(typeof(arg) : long) || is(typeof(arg) : ulong)) |
| 33 |
{ |
| 34 |
if (i != index) continue; |
| 35 |
return cast(int)(arg); |
| 36 |
} |
| 37 |
else |
| 38 |
{ |
| 39 |
if (i == index) break; |
| 40 |
} |
| 41 |
} |
| 42 |
throw new Error("int expected"); |
| 43 |
} |
| 44 |
|
| 45 |
/******************************************/ |
| 46 |
|
| 47 |
class Foo2 { |
| 48 |
int foo() { |
| 49 |
synchronized(this){ |
| 50 |
return 8; |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/******************************************/ |
| 56 |
|
| 57 |
void mainX() |
| 58 |
{ |
| 59 |
int i=0; |
| 60 |
printf("This number is zero: "); |
| 61 |
goto inloop; |
| 62 |
for(; i<10; i++) { // this is line 7 |
| 63 |
printf("This number is nonzero: "); |
| 64 |
inloop: |
| 65 |
printf("%d\n", i); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
/******************************************/ |
| 70 |
|
| 71 |
string foo3(int bar) |
| 72 |
{ |
| 73 |
switch (bar) |
| 74 |
{ |
| 75 |
case 1: |
| 76 |
return "1"; |
| 77 |
case 2: |
| 78 |
return "2"; |
| 79 |
default: |
| 80 |
return "3"; |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
/******************************************/ |
| 86 |
|
| 87 |
int foo4() |
| 88 |
{ |
| 89 |
int i; |
| 90 |
for (;; ++i) |
| 91 |
{ |
| 92 |
if (i == 10) return 0; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
/******************************************/ |
| 97 |
|
| 98 |
int foo5() |
| 99 |
{ |
| 100 |
do { |
| 101 |
if (false) |
| 102 |
return 1; |
| 103 |
} while (true); |
| 104 |
} |
| 105 |
|
| 106 |
/******************************************/ |
| 107 |
|
| 108 |
nothrow int foo6() |
| 109 |
{ |
| 110 |
int x = 2; |
| 111 |
try |
| 112 |
{ |
| 113 |
} |
| 114 |
catch(Exception e) |
| 115 |
{ |
| 116 |
x = 4; |
| 117 |
throw new Exception("xxx"); |
| 118 |
} |
| 119 |
return x; |
| 120 |
} |
| 121 |
|
| 122 |
/******************************************/ |
| 123 |
// https://issues.dlang.org/show_bug.cgi?id=6518 |
| 124 |
|
| 125 |
template TypeTuple(T...) { alias T TypeTuple; } |
| 126 |
void test6518() |
| 127 |
{ |
| 128 |
switch(2) |
| 129 |
{ |
| 130 |
foreach(v; TypeTuple!(1, 2, 3)) |
| 131 |
case v: break; |
| 132 |
default: assert(0); |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
/***************************************************/ |
| 137 |
|
| 138 |
struct S9332 |
| 139 |
{ |
| 140 |
this(S9332) |
| 141 |
{ |
| 142 |
// while (1) { } |
| 143 |
assert(0, "unreachable?"); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
/******************************************/ |
| 148 |
// https://issues.dlang.org/show_bug.cgi?id=13201 |
| 149 |
|
| 150 |
class C13201 |
| 151 |
{ |
| 152 |
void foo() |
| 153 |
{ |
| 154 |
synchronized(this) |
| 155 |
{ |
| 156 |
assert(0); |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
void test13201a() |
| 162 |
{ |
| 163 |
auto c = new C13201(); |
| 164 |
synchronized(c) |
| 165 |
{ |
| 166 |
assert(0); |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
void test13201b() |
| 171 |
{ |
| 172 |
struct S { ~this() {} } |
| 173 |
|
| 174 |
S s; |
| 175 |
assert(0); |
| 176 |
} |
| 177 |
|
| 178 |
/******************************************/ |
| 179 |
|
| 180 |
void main() |
| 181 |
{ |
| 182 |
} |