]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/diag16977.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / diag16977.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag16977.d(22): Error: undefined identifier `undefined`, did you mean function `undefinedId`?
5 fail_compilation/diag16977.d(23): Error: cannot implicitly convert expression `"\x01string"` of type `string` to `int`
6 fail_compilation/diag16977.d(24): Error: template diag16977.templ cannot deduce function from argument types !()(int), candidates are:
7 fail_compilation/diag16977.d(17): diag16977.templ(S)(S s) if (false)
8 fail_compilation/diag16977.d(25): Error: cannot implicitly convert expression `5` of type `int` to `string`
9 fail_compilation/diag16977.d(27): Error: template instance diag16977.test.funcTemplate!string error instantiating
10 ---
11 */
12
13 // when copying the expression of a default argument, location information is
14 // replaced by the location of the caller to improve debug information
15 // verify error messages are displayed for the original location only
16
17 string templ(S)(S s) if(false) { return null; }
18
19 void test()
20 {
21 // local functions to defer evaluation into semantic3 pass
22 void undefinedId(int x, int y = undefined) {}
23 void badOp(int x, int y = 1 ~ "string") {}
24 void lazyTemplate(int x, lazy int y = 4.templ) {}
25 void funcTemplate(T)(T y = 5) {}
26
27 funcTemplate!string();
28 undefinedId(1);
29 badOp(2);
30 lazyTemplate(3);
31 }