summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test21807.d
blob: 9f56bf73a90ee265680d45d67b8a8dc4b6d4fb73 (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
/*
https://issues.dlang.org/show_bug.cgi?id=21807

REQUIRED_ARGS: -de
TEST_OUTPUT:
---
fail_compilation/test21807.d(11): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.str`
fail_compilation/test21807.d(12): Deprecation: slice of static array temporary returned by `getSArray()` assigned to longer lived variable `this.ca`
---
*/
#line 1

char[12] getSArray() pure;

class Foo
{
	string str;
	char[] ca;

	this()
	{
		str = getSArray(); // Should probably be a type error
		ca = getSArray();
	}
}

/*
TEST_OUTPUT:
---
fail_compilation/test21807.d(117): Error: function `test21807.addr(return ref int b)` is not callable using argument types `(int)`
fail_compilation/test21807.d(117):        cannot pass rvalue argument `S(0).i` of type `int` to parameter `return ref int b`
---
*/
#line 100

struct S
{
	int i;
}

int* addr(return ref int b)
{
	return &b;
}

class Foo2
{
	int* ptr;

	this()
	{
		ptr = addr(S().i);  // struct temporary
	}
}