dmd/compiler/test/fail_compilation/fail3882.d
Iain Buclaw f4be7f6f7b
Remove warning for discarded return value (#15718)
Either this is valid code, or it is rejected by the language and backed
up by the spec. Since we now have `@mustuse`, this warning makes even
less sense to keep around as applying the attribute would make such code
an error in the future when/if it gets implemented for functions.
2023-10-22 16:04:27 +08:00

39 lines
831 B
D

/*
PERMUTE_ARGS: -debug
TEST_OUTPUT:
---
fail_compilation/fail3882.d(32): Error: `@mustuse` on functions is reserved for future use
fail_compilation/fail3882.d(33): Error: `@mustuse` on functions is reserved for future use
---
*/
import core.attribute;
/******************************************/
// https://issues.dlang.org/show_bug.cgi?id=3882
@mustuse @safe pure nothrow T strictlyPure(T)(T x)
{
return x*x;
}
void main()
{
int x = 3;
strictlyPure(x);
// https://issues.dlang.org/show_bug.cgi?id=12649
auto fp = &strictlyPure!int;
fp(x);
}
/******************************************/
// bugfix in TypeFunction::purityLevel
@mustuse nothrow pure int f1(immutable(int)[] a) { return 0; }
@mustuse nothrow pure int f2(immutable(int)* p) { return 0; }
void test_bug()
{
f1([]);
f2(null);
}