| 1 |
/* { dg-options "--coverage -fpath-coverage" } */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
#include <stdexcept> |
| 5 |
|
| 6 |
/* This test is a collection of odd CFG shapes which has been shown to |
| 7 |
trigger ICEs. */ |
| 8 |
|
| 9 |
/* A hard abort-like exit could lead to paths with only the exit node, |
| 10 |
which would then be an empty path after entry/exit prunng. |
| 11 |
|
| 12 |
BEGIN paths |
| 13 |
summary: 0/1 */ |
| 14 |
void xabort () { __builtin_exit (0); } |
| 15 |
/* END */ |
| 16 |
|
| 17 |
/* Unconditional exceptions have the same effect as aborts |
| 18 |
w.r.t. empty paths. */ |
| 19 |
int throws (int) { throw std::runtime_error("exception"); } |
| 20 |
|
| 21 |
int _setjmp (void **); |
| 22 |
/* Bad instrumentation would give |
| 23 |
'error: returns_twice call is not first in basic block 3'. |
| 24 |
|
| 25 |
BEGIN paths |
| 26 |
summary: 0/1 */ |
| 27 |
void set_jmp () |
| 28 |
/* END */ |
| 29 |
{ |
| 30 |
_setjmp (0); |
| 31 |
} |
| 32 |
|
| 33 |
/* From g++.dg/torture/pr83482.C */ |
| 34 |
void a(); |
| 35 |
struct b { |
| 36 |
virtual long c() { return 0L; } |
| 37 |
void m_fn2() { c(); } |
| 38 |
} d; |
| 39 |
|
| 40 |
/* BEGIN paths |
| 41 |
summary: 0/3 */ |
| 42 |
void e() { |
| 43 |
/* END */ |
| 44 |
d.m_fn2(); |
| 45 |
try { |
| 46 |
a(); |
| 47 |
_setjmp(0); |
| 48 |
} catch (...) { |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
/* BEGIN paths |
| 53 |
summary: 0/1 */ |
| 54 |
void multiple_setjmp () |
| 55 |
/* END */ |
| 56 |
{ |
| 57 |
_setjmp (0); |
| 58 |
_setjmp (0); |
| 59 |
} |
| 60 |
|
| 61 |
/* loop_setjmp and loop_setjmp_continue are based on patterns found in |
| 62 |
expat-2.5.0 tests/minicheck.c srunner_run_all. */ |
| 63 |
void loop_setjmp (int n) |
| 64 |
{ |
| 65 |
for (int i = 0; i < n; ++i) |
| 66 |
_setjmp (0); |
| 67 |
} |
| 68 |
|
| 69 |
void loop_setjmp_continue (int n) |
| 70 |
{ |
| 71 |
for (int i = 0; i < n; ++i) |
| 72 |
{ |
| 73 |
if (i < n / 4) |
| 74 |
if (_setjmp (0)) |
| 75 |
continue; |
| 76 |
|
| 77 |
if (_setjmp (0)) |
| 78 |
continue; |
| 79 |
|
| 80 |
if (i < n / 2) |
| 81 |
if (_setjmp (0)) |
| 82 |
continue; |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
void loop_setjmp_infinite (int n) |
| 87 |
{ |
| 88 |
for (;;) |
| 89 |
_setjmp (0); |
| 90 |
} |
| 91 |
|
| 92 |
/* BEGIN paths |
| 93 |
summary: 0/2 */ |
| 94 |
void multiple_conditional_setjmp (int a) |
| 95 |
/* END */ |
| 96 |
{ |
| 97 |
if (a) |
| 98 |
_setjmp (0); |
| 99 |
else |
| 100 |
_setjmp (0); |
| 101 |
|
| 102 |
_setjmp (0); |
| 103 |
} |
| 104 |
|
| 105 |
/* Infinite loops can create CFGs that are a bit different, e.g. no edge for |
| 106 |
skipping or brekaing out of the loop. */ |
| 107 |
int id (int x) { return x; } |
| 108 |
int infinite1 () |
| 109 |
{ |
| 110 |
for (int c = 0; ; c++) id (c); |
| 111 |
} |
| 112 |
|
| 113 |
void infinite2 () |
| 114 |
{ |
| 115 |
for (;;) {} |
| 116 |
} |
| 117 |
|
| 118 |
/* This function has multiple SCCs (loops), but one has too many internal paths |
| 119 |
(2^32). If the scc-internal-paths is not limited this function will not |
| 120 |
compile in reasonable time. */ |
| 121 |
#pragma GCC diagnostic push |
| 122 |
#pragma GCC diagnostic ignored "-Wcoverage-too-many-paths" |
| 123 |
void too_many_paths_single_scc (int x) |
| 124 |
{ |
| 125 |
int z = 0; |
| 126 |
int c = 0; |
| 127 |
|
| 128 |
for (int i = 0; i != x; ++i) |
| 129 |
for (int k = i; k != x; ++k) |
| 130 |
c++; |
| 131 |
|
| 132 |
for (int i = 0; i != 100; ++i) |
| 133 |
{ |
| 134 |
if (z + i + 0 < x) z++; |
| 135 |
if (z + i + 1 < x) z++; |
| 136 |
if (z + i + 2 < x) z++; |
| 137 |
if (z + i + 3 < x) z++; |
| 138 |
if (z + i + 4 < x) z++; |
| 139 |
if (z + i + 5 < x) z++; |
| 140 |
if (z + i + 6 < x) z++; |
| 141 |
if (z + i + 7 < x) z++; |
| 142 |
if (z + i + 8 < x) z++; |
| 143 |
if (z + i + 9 < x) z++; |
| 144 |
if (z + i + 10 < x) z++; |
| 145 |
if (z + i + 11 < x) z++; |
| 146 |
if (z + i + 12 < x) z++; |
| 147 |
if (z + i + 13 < x) z++; |
| 148 |
if (z + i + 14 < x) z++; |
| 149 |
if (z + i + 15 < x) z++; |
| 150 |
if (z + i + 16 < x) z++; |
| 151 |
if (z + i + 17 < x) z++; |
| 152 |
if (z + i + 18 < x) z++; |
| 153 |
if (z + i + 19 < x) z++; |
| 154 |
if (z + i + 20 < x) z++; |
| 155 |
if (z + i + 21 < x) z++; |
| 156 |
if (z + i + 22 < x) z++; |
| 157 |
if (z + i + 23 < x) z++; |
| 158 |
if (z + i + 24 < x) z++; |
| 159 |
if (z + i + 25 < x) z++; |
| 160 |
if (z + i + 26 < x) z++; |
| 161 |
if (z + i + 27 < x) z++; |
| 162 |
if (z + i + 28 < x) z++; |
| 163 |
if (z + i + 29 < x) z++; |
| 164 |
if (z + i + 30 < x) z++; |
| 165 |
if (z + i + 31 < x) z++; |
| 166 |
} |
| 167 |
} |
| 168 |
#pragma GCC diagnostic pop |
| 169 |
|
| 170 |
/* { dg-final { run-gcov prime-paths { --prime-paths gcov-22.C } } } */ |