Skip to content

Commit 6ae8bd0

Browse files
committed
tests: add compilable and failure cases for DIP1029
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
1 parent 3c253b0 commit 6ae8bd0

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

test/compilable/dip1029.d

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
void foo() {}
3+
4+
void foobar() throw {}
5+
void bar() nothrow {}
6+
7+
nothrow {
8+
void n_t() throw;
9+
}
10+
11+
void _t();
12+
void t() throw;
13+
14+
15+
struct S2 {
16+
void foo() {
17+
_t();
18+
t();
19+
n_t();
20+
}
21+
}
22+
23+
nothrow:
24+
void t2() throw;
25+
26+
throw:
27+
void n2() nothrow;
28+

test/fail_compilation/dip1029_1.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
fail_compilation/dip1029_1.d(101): Error: redundant attribute `throw`
5+
fail_compilation/dip1029_1.d(102): Error: conflicting attribute `nothrow`
6+
---
7+
*/
8+
9+
#line 100
10+
11+
void tt() throw throw;
12+
void tn() throw nothrow;
13+

test/fail_compilation/dip1029_2.d

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
fail_compilation/dip1029_2.d(211): Error: function `dip1029_2._t` is not `nothrow`
5+
fail_compilation/dip1029_2.d(212): Error: function `dip1029_2.t` is not `nothrow`
6+
fail_compilation/dip1029_2.d(213): Error: function `dip1029_2.n_t` is not `nothrow`
7+
fail_compilation/dip1029_2.d(210): Error: `nothrow` function `dip1029_2.S1.foo` may throw
8+
---
9+
*/
10+
11+
#line 200
12+
13+
nothrow {
14+
void n_t() throw;
15+
void n_n();
16+
}
17+
18+
void _t();
19+
void t() throw;
20+
21+
struct S1 {
22+
nothrow void foo() {
23+
_t();
24+
t();
25+
n_t();
26+
n_n();
27+
}
28+
}
29+

0 commit comments

Comments
 (0)