d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / var_func_attr.d
blob8609d29b58cbc3a0ede1525ce30060e258747a07
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/var_func_attr.d(19): Error: cannot implicitly convert expression `__lambda8` of type `void function() nothrow @nogc @safe` to `void function() pure`
5 ---
6 */
8 // Test the effect of function attributes on variables
9 // See:
10 // https://issues.dlang.org/show_bug.cgi?id=7432
11 // https://github.com/dlang/dmd/pull/14199
12 // Usually it's a no-op, but the attribute can apply to the function/delegate type of the variable
13 // The current behavior is weird, so this is a test of the current behavior, not necessarily the desired behavior
15 // No-op
16 pure int x;
18 // Applies to function type (existing code in dmd and Phobos relies on this)
19 pure void function() pf = () {
20 static int g;
21 g++;
24 // Function attributes currently don't apply to inferred types (somewhat surprisingly)
25 nothrow nf = () {
26 throw new Exception("");
29 // Neither do they apply to indirections
30 alias F = void function();
32 pure F pf2 = () {
33 static int g;
34 g++;