testsuite: Fix tail_call and musttail effective targets [PR116080]
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-79.c
blob87bf775c0b2be0c8cef5377faa353d6c23d374d2
1 /* Verify that a separate note is issued for each offset into the same
2 object after a -Wstringop-overflow. Since all arguments are known
3 the test doesn't need optimization. Wstringop-overflow-79.c verifies
4 they're also issued at -O2.
5 { dg-do compile }
6 { dg-options "-O0 -Wno-array-bounds" } */
8 extern char a[8]; // { dg-message "at offset \\\[3, 6] into destination object 'a'" "note 1" }
9 // { dg-message "at offset \\\[5, 8] into destination object 'a'" "note 2" { target *-*-* } .-1 }
11 void test_2_notes (int i)
13 char *p = i ? a + 3 : a + 5;
14 __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" }
18 extern char b[8]; // { dg-message "at offset \\\[3, 6] into destination object 'b'" "note 1" }
19 // { dg-message "at offset \\\[4, 7] into destination object 'b'" "note 2" { target *-*-* } .-1 }
20 // { dg-message "at offset \\\[5, 8] into destination object 'b'" "note 3" { target *-*-* } .-2 }
22 void test_3_notes (int i)
24 char *p = i < 0 ? b + 3 : 0 < i ? b + 5 : b + 4;
25 __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" }
29 extern char c[8]; // { dg-message "at offset \\\[3, 6] into destination object 'c'" "note 1" }
30 // { dg-message "at offset \\\[4, 7] into destination object 'c'" "note 2" { target *-*-* } .-1 }
31 // { dg-message "at offset \\\[5, 8] into destination object 'c'" "note 3" { target *-*-* } .-2 }
32 // { dg-message "at offset \\\[6, 8] into destination object 'c'" "note 4" { target *-*-* } .-3 }
34 void test_4_notes (int i)
36 char *p;
37 if (i < -1)
38 p = c + 3;
39 else if (i < 0)
40 p = c + 4;
41 else if (0 < i)
42 p = c + 6;
43 else
44 p = c + 5;
46 __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" }
50 extern char d[8]; // { dg-message "at offset \\\[3, 6] into destination object 'd'" "note 1" }
51 // { dg-message "at offset \\\[4, 7] into destination object 'd'" "note 2" { target *-*-* } .-1 }
52 // { dg-message "at offset \\\[5, 8] into destination object 'd'" "note 3" { target *-*-* } .-2 }
53 // { dg-message "at offset \\\[6, 8] into destination object 'd'" "note 4" { target *-*-* } .-3 }
54 // { dg-message "at offset \\\[7, 8] into destination object 'd'" "note 5" { target *-*-* } .-4 }
56 void test_5_notes (int i)
58 char *p;
59 switch (i)
61 case -9: p = d + 3; break;
62 case -5: p = d + 4; break;
63 case 0: p = d + 5; break;
64 case 3: p = d + 6; break;
65 case 4: p = d + 7; break;
66 default: return;
69 __builtin_memset (p, 0, 7); // { dg-warning "-Wstringop-overflow" }