]> git.ipfire.org Git - people/ms/gcc.git/blob - gcc/testsuite/gdc.test/fail_compilation/diag3438.d
c4cbc721d860f7f199bf85fcc22660f8b7ee215f
[people/ms/gcc.git] / gcc / testsuite / gdc.test / fail_compilation / diag3438.d
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/diag3438.d(16): Error: constructor `diag3438.F1.this` all parameters have default arguments, but structs cannot have default constructors.
5 fail_compilation/diag3438.d(17): Error: constructor `diag3438.F2.this` all parameters have default arguments, but structs cannot have default constructors.
6 fail_compilation/diag3438.d(20): Error: constructor `diag3438.F5.this` is marked `@disable`, so it cannot have default arguments for all parameters.
7 fail_compilation/diag3438.d(20): Use `@disable this();` if you want to disable default initialization.
8 fail_compilation/diag3438.d(21): Error: constructor `diag3438.F6.this` is marked `@disable`, so it cannot have default arguments for all parameters.
9 fail_compilation/diag3438.d(21): Use `@disable this();` if you want to disable default initialization.
10 fail_compilation/diag3438.d(24): Error: default argument expected for `y`
11 ---
12 */
13
14 import core.vararg;
15
16 struct F1 { this(int x = 1) { } }
17 struct F2 { this(int x = 1, ...) { } }
18 struct F3 { this(...) { } } // ok
19 struct F4 { this(int[] x...) { } } // ok
20 struct F5 { @disable this(int x = 1); }
21 struct F6 { @disable this(int x = 1) { } }
22
23 // Make sure the deprecation doesn't interfere w/ the check for default arguments
24 struct S { this(int x = 1, int y) { } }