| 1 |
// PR bootstrap/111601 |
| 2 |
// { dg-do run { target c++11 } } |
| 3 |
// { dg-options "-O2 -fno-exceptions -fno-rtti -fprofile-generate" } |
| 4 |
// { dg-require-profiling "-fprofile-generate" } |
| 5 |
// { dg-final { cleanup-coverage-files } } |
| 6 |
|
| 7 |
struct tree_base |
| 8 |
{ |
| 9 |
int code:16; |
| 10 |
}; |
| 11 |
struct saved_scope |
| 12 |
{ |
| 13 |
void *pad[14]; |
| 14 |
int x_processing_template_decl; |
| 15 |
}; |
| 16 |
struct saved_scope *scope_chain; |
| 17 |
struct z_candidate |
| 18 |
{ |
| 19 |
tree_base *fn; |
| 20 |
void *pad[11]; |
| 21 |
z_candidate *next; |
| 22 |
int viable; |
| 23 |
int flags; |
| 24 |
}; |
| 25 |
|
| 26 |
__attribute__((noipa)) struct z_candidate * |
| 27 |
splice_viable (struct z_candidate *cands, bool strict_p, bool *any_viable_p) |
| 28 |
{ |
| 29 |
struct z_candidate *viable; |
| 30 |
struct z_candidate **last_viable; |
| 31 |
struct z_candidate **cand; |
| 32 |
bool found_strictly_viable = false; |
| 33 |
if (scope_chain->x_processing_template_decl) |
| 34 |
strict_p = true; |
| 35 |
viable = (z_candidate *) 0; |
| 36 |
last_viable = &viable; |
| 37 |
*any_viable_p = false; |
| 38 |
cand = &cands; |
| 39 |
while (*cand) |
| 40 |
{ |
| 41 |
struct z_candidate *c = *cand; |
| 42 |
if (!strict_p && (c->viable == 1 || ((int) (c->fn)->code) == 273)) |
| 43 |
{ |
| 44 |
strict_p = true; |
| 45 |
if (viable && !found_strictly_viable) |
| 46 |
{ |
| 47 |
*any_viable_p = false; |
| 48 |
*last_viable = cands; |
| 49 |
cands = viable; |
| 50 |
viable = (z_candidate *) 0; |
| 51 |
last_viable = &viable; |
| 52 |
} |
| 53 |
} |
| 54 |
if (strict_p ? c->viable == 1 : c->viable) |
| 55 |
{ |
| 56 |
*last_viable = c; |
| 57 |
*cand = c->next; |
| 58 |
c->next = (z_candidate *) 0; |
| 59 |
last_viable = &c->next; |
| 60 |
*any_viable_p = true; |
| 61 |
if (c->viable == 1) |
| 62 |
found_strictly_viable = true; |
| 63 |
} |
| 64 |
else |
| 65 |
cand = &c->next; |
| 66 |
} |
| 67 |
return viable ? viable : cands; |
| 68 |
} |
| 69 |
|
| 70 |
int |
| 71 |
main () |
| 72 |
{ |
| 73 |
saved_scope s{}; |
| 74 |
scope_chain = &s; |
| 75 |
z_candidate z[4] = {}; |
| 76 |
z[0].next = &z[1]; |
| 77 |
z[1].viable = 1; |
| 78 |
z[1].next = &z[2]; |
| 79 |
z[2].viable = 1; |
| 80 |
z[2].next = &z[3]; |
| 81 |
bool b; |
| 82 |
z_candidate *c = splice_viable (&z[0], true, &b); |
| 83 |
if (c != &z[1] || z[1].next != &z[2] || z[2].next) |
| 84 |
__builtin_abort (); |
| 85 |
return 0; |
| 86 |
} |