aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/bug6963.d
blob: 33d595cfedbc7d900ff2fe3610c33b7d112910db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// PERMUTE_ARGS:
// REQUIRED_ARGS:

/*
TEST_OUTPUT:
---
output foo: 1e: pure nothrow @nogc @safe void(int x)
output foo: 3e: pure nothrow @nogc @safe void(int x)
---
*/

alias void function(int) pure nothrow @safe @nogc FuncPtrType;

void foo1a(X)(X x) {}
void foo1b(X)(X x) {}
void foo1c(X)(X x) {}
void foo1d(X)(X x) {}
void foo1e(X)(X x) {}

// module level declaration with type inference
auto fptr1 = &foo1a!int;
static assert(is(typeof(fptr1) == FuncPtrType));

// array initializer
auto fptrlist1 = [&foo1b!int];
static assert(is(typeof(fptrlist1) == FuncPtrType[]));

// static assert
static assert(is(typeof(&foo1c!int) == FuncPtrType));

// static if
static if(is(typeof(&foo1d!int) PF))
    static assert(is(PF == FuncPtrType));
else
    static assert(0);

// pragma test
pragma(msg, "output foo: 1e: ", typeof(foo1e!int).stringof);

void foo2a(X)(X x) {}
void foo2b(X)(X x) {}
void foo2c(X)(X x) {}

FuncPtrType fptr3 = &foo2a!int;     // most similar to original issue

FuncPtrType[] fptrlist3 = [&foo2b!int];

struct S{ FuncPtrType fp; }
S s = { &foo2c!int };

void foo3a(X)(X x) {}
void foo3b(X)(X x) {}
void foo3c(X)(X x) {}
void foo3d(X)(X x) {}
void foo3e(X)(X x) {}

void main()
{
    auto fptr2 = &foo3a!int;
    static assert(is(typeof(fptr2) == FuncPtrType));

    auto fptrlist2 = [&foo3b!int];
    static assert(is(typeof(fptrlist2) == FuncPtrType[]));

    static assert(is(typeof(&foo1c!int) == FuncPtrType));

    static if(is(typeof(&foo1d!int) PF))
        static assert(is(PF == FuncPtrType));
    else
        static assert(0);

    pragma(msg, "output foo: 3e: ", typeof(foo3e!int));
}