| 1 |
/* REQUIRED_ARGS: -o- |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/commaexp.d(27): Error: using the result of a comma expression is not allowed |
| 5 |
fail_compilation/commaexp.d(39): Error: using the result of a comma expression is not allowed |
| 6 |
fail_compilation/commaexp.d(40): Error: using the result of a comma expression is not allowed |
| 7 |
fail_compilation/commaexp.d(41): Error: using the result of a comma expression is not allowed |
| 8 |
fail_compilation/commaexp.d(42): Error: using the result of a comma expression is not allowed |
| 9 |
fail_compilation/commaexp.d(44): Error: using the result of a comma expression is not allowed |
| 10 |
fail_compilation/commaexp.d(45): Error: using the result of a comma expression is not allowed |
| 11 |
fail_compilation/commaexp.d(56): Error: using the result of a comma expression is not allowed |
| 12 |
fail_compilation/commaexp.d(69): Error: using the result of a comma expression is not allowed |
| 13 |
fail_compilation/commaexp.d(81): Error: using the result of a comma expression is not allowed |
| 14 |
--- |
| 15 |
*/ |
| 16 |
|
| 17 |
class Entry {} |
| 18 |
class MyContainerClass { bool append (Entry) { return false; } } |
| 19 |
|
| 20 |
int main () { |
| 21 |
bool ok; |
| 22 |
size_t aggr; |
| 23 |
MyContainerClass mc; |
| 24 |
|
| 25 |
// https://issues.dlang.org/show_bug.cgi?id=15997 |
| 26 |
enum WINHTTP_ERROR_BASE = 4200; |
| 27 |
enum ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED = (WINHTTP_ERROR_BASE, + 44); |
| 28 |
|
| 29 |
// OK |
| 30 |
for (size_t i; i < 5; ++i, i += 1) {} |
| 31 |
for (size_t i; i < 5; ++i, i += 1, i++) {} |
| 32 |
if (!mc) |
| 33 |
mc = new MyContainerClass, mc.append(new Entry); |
| 34 |
if (Object o = cast(Object)mc) {} // Lowering |
| 35 |
ok = true, mc.append(new Entry); |
| 36 |
assert(ok); |
| 37 |
|
| 38 |
// NOPE |
| 39 |
for (size_t i; i < 5; ++i, i += (i++, 1)) {} |
| 40 |
for (; aggr++, aggr > 5;) {} |
| 41 |
if (Object o = (ok = true, null)) {} |
| 42 |
ok = (true, mc.append(new Entry)); |
| 43 |
assert(!ok); |
| 44 |
ok = true, (ok = (true, false)); |
| 45 |
return 42, 0; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
/***************************************************/ |
| 50 |
// https://issues.dlang.org/show_bug.cgi?id=16022 |
| 51 |
|
| 52 |
bool test16022() |
| 53 |
{ |
| 54 |
enum Type { Colon, Comma } |
| 55 |
Type type; |
| 56 |
return type == Type.Colon, type == Type.Comma; |
| 57 |
} |
| 58 |
|
| 59 |
bool test16022_structs() |
| 60 |
{ |
| 61 |
struct A |
| 62 |
{ |
| 63 |
int i; |
| 64 |
string s; |
| 65 |
} |
| 66 |
|
| 67 |
enum Type { Colon = A(0, "zero"), Comma = A(1, "one") } |
| 68 |
Type type; |
| 69 |
return type == Type.Colon, type == Type.Comma; |
| 70 |
} |
| 71 |
|
| 72 |
/********************************************/ |
| 73 |
|
| 74 |
|
| 75 |
void bar11(int*, int*) { } |
| 76 |
|
| 77 |
void test11() |
| 78 |
{ |
| 79 |
static int* p; |
| 80 |
static int i; |
| 81 |
bar11((i,p), &i); |
| 82 |
} |