111
|
1 /* Verify that NRV optimizations are prohibited when the LHS is
|
|
2 something that may be call-clobbered. */
|
|
3 /* { dg-do compile } */
|
|
4 /* { dg-options "-O -fdump-tree-optimized" } */
|
|
5
|
|
6 typedef struct { int x[20]; void *y; } S;
|
|
7 typedef struct { int a; S b; } T;
|
|
8 S nrv_candidate (void);
|
|
9 void use_result (S);
|
|
10 void make_escape (S *);
|
|
11 void foo (void)
|
|
12 {
|
|
13 S result;
|
|
14 T result_arr[10][5];
|
|
15
|
|
16 make_escape (&result);
|
|
17 make_escape (&(result_arr[3][4].b));
|
|
18
|
|
19 /* Neither call should be allowed to use NRV optimization. */
|
|
20 result = nrv_candidate ();
|
|
21 result_arr[3][4].b = nrv_candidate ();
|
|
22
|
|
23 use_result (result);
|
|
24 use_result (result_arr[3][4].b);
|
|
25 }
|
|
26
|
|
27 /* { dg-final { scan-tree-dump-times "return slot optimization" 0 "optimized" } } */
|