d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / fail3882.d
blob27ddad41604df7b764180cacd1dfd4ac696c125f
1 // REQUIRED_ARGS: -w
2 // PERMUTE_ARGS: -debug
4 /******************************************/
5 // https://issues.dlang.org/show_bug.cgi?id=3882
7 /*
8 TEST_OUTPUT:
9 ---
10 fail_compilation/fail3882.d(23): Warning: calling `fail3882.strictlyPure!int.strictlyPure` without side effects discards return value of type `int`; prepend a `cast(void)` if intentional
11 fail_compilation/fail3882.d(27): Warning: calling `fp` without side effects discards return value of type `int`; prepend a `cast(void)` if intentional
12 ---
15 @safe pure nothrow T strictlyPure(T)(T x)
17 return x*x;
20 void main()
22 int x = 3;
23 strictlyPure(x);
25 // https://issues.dlang.org/show_bug.cgi?id=12649
26 auto fp = &strictlyPure!int;
27 fp(x);
30 /******************************************/
31 // bugfix in TypeFunction::purityLevel
34 TEST_OUTPUT:
35 ---
36 fail_compilation/fail3882.d(48): Warning: calling `fail3882.f1` without side effects discards return value of type `int`; prepend a `cast(void)` if intentional
37 fail_compilation/fail3882.d(49): Warning: calling `fail3882.f2` without side effects discards return value of type `int`; prepend a `cast(void)` if intentional
38 Error: warnings are treated as errors
39 Use -wi if you wish to treat warnings only as informational.
40 ---
43 nothrow pure int f1(immutable(int)[] a) { return 0; }
44 nothrow pure int f2(immutable(int)* p) { return 0; }
46 void test_bug()
48 f1([]);
49 f2(null);