Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail3.d

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail3.d(42): Error: operator `+` is not defined for type `vec2`
5 fail_compilation/fail3.d(13): perhaps overload the operator with `auto opBinary(string op : "+")(vec2 rhs) {}`
6 ---
7 */
8
9 // DMD 0.79 linux: Internal error: ../ztc/cgcod.c 1459
10
11 template vector(T)
12 {
13 struct vec2
14 {
15 T x, y;
16 }
17
18 // not struct member
19 vec2 opAdd(vec2 a, vec2 b)
20 {
21 vec2 r;
22 r.x = a.x + b.x;
23 r.y = a.y + b.y;
24 return r;
25 }
26
27 vec2 make2(T x, T y)
28 {
29 vec2 a;
30 a.x = x;
31 a.y = y;
32 return a;
33 }
34 }
35
36 alias vector!(float).vec2 vec2f;
37
38 int main()
39 {
40 vec2f a, b;
41 b.x = 3;
42 a = a + b;
43 //printf("%f\n", a.x);
44 return 0;
45 }