MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / commaexp.d
blob3874fb18ef1027210c2c52454539b6108ee5f04b
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 ---
17 class Entry {}
18 class MyContainerClass { bool append (Entry) { return false; } }
20 int main () {
21 bool ok;
22 size_t aggr;
23 MyContainerClass mc;
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);
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);
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;
49 /***************************************************/
50 // https://issues.dlang.org/show_bug.cgi?id=16022
52 bool test16022()
54 enum Type { Colon, Comma }
55 Type type;
56 return type == Type.Colon, type == Type.Comma;
59 bool test16022_structs()
61 struct A
63 int i;
64 string s;
67 enum Type { Colon = A(0, "zero"), Comma = A(1, "one") }
68 Type type;
69 return type == Type.Colon, type == Type.Comma;
72 /********************************************/
75 void bar11(int*, int*) { }
77 void test11()
79 static int* p;
80 static int i;
81 bar11((i,p), &i);