mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00

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.
39 lines
831 B
D
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);
|
|
}
|