MATCH: Improve `A CMP 0 ? A : -A` set of patterns to use bitwise_equal_p.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / dip1000_deprecation.d
blob77ab52046fc81368cb4e87ba455d61985c2c763a
1 /*
2 REQUIRED_ARGS: -de
3 TEST_OUTPUT:
4 ---
5 fail_compilation/dip1000_deprecation.d(17): Deprecation: `@safe` function `main` calling `inferred`
6 fail_compilation/dip1000_deprecation.d(25): which wouldn't be `@safe` because of:
7 fail_compilation/dip1000_deprecation.d(25): scope variable `x0` may not be returned
8 fail_compilation/dip1000_deprecation.d(19): Deprecation: `@safe` function `main` calling `inferredC`
9 fail_compilation/dip1000_deprecation.d(36): which calls `dip1000_deprecation.inferred`
10 fail_compilation/dip1000_deprecation.d(25): which wouldn't be `@safe` because of:
11 fail_compilation/dip1000_deprecation.d(25): scope variable `x0` may not be returned
12 ---
15 void main() @safe
17 cast(void)inferred();
18 cast(void)inferredB(); // no deprecation, trusted
19 cast(void)inferredC(); // nested deprecation
22 auto inferred()
24 scope int* x0;
25 return x0;
28 auto inferredB() @trusted
30 scope int* x1;
31 return x1;
34 auto inferredC()
36 return inferred(); // no deprecation, inferredC is not explicit `@safe`
39 @safe:
41 struct S
43 int* ptr;
44 int* incorrectReturnRef() scope return @trusted {return ptr;}
47 S createS() { return S.init; }
49 int* escape(int i)
51 if (i) return S().incorrectReturnRef();
52 if (i) return createS().incorrectReturnRef();
54 S s;
55 return s.incorrectReturnRef();