Debian Codegraph @

gcc/testsuite/gcc.dg/ubsan/bitint-3.c

raw
1 /* PR c/102989 */
2 /* { dg-do run { target bitint575 } } */
3 /* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */
4
5 __attribute__((noipa)) int
6 foo (_BitInt(575) *p, _BitInt(575) *q, int n)
7 {
8 q[0] = p[0] + p[1];
9 q[1] = p[2] - p[3];
10 q[2] = p[4] * p[5];
11 q[3] = p[6] / p[7];
12 q[4] = p[8] << n;
13 q[5] = p[9] >> n;
14 return n;
15 }
16
17 int
18 main ()
19 {
20 static _BitInt(575) p[] = {
21 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174782wb, 1wb,
22 -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb,
23 248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766529wb,
24 -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb,
25 0wb, 1wb,
26 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb,
27 -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb,
28 248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766530wb,
29 -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, -1wb,
30 0wb, 1wb
31 };
32 _BitInt(575) q[6];
33 foo (p, q, 574);
34 foo (p + 10, q, 575);
35 }
36
37 /* These print unsigned integer overflow even when it is signed. */
38 /* { dg-output "signed integer overflow: <unknown> \\+ <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
39 /* { dg-output "\[^\n\r]*signed integer overflow: <unknown> - <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
40 /* { dg-output "\[^\n\r]*signed integer overflow: <unknown> \\* <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
41 /* Inaccurate. */
42 /* { dg-output "\[^\n\r]*division by zero\[^\n\r]*(\n|\r\n|\r)" } */
43 /* The wording is totally incorrect, but at least it is diagnosed. */
44 /* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
45 /* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'" } */