]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/pragma-diag-9.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / pragma-diag-9.c
CommitLineData
6d3bab5d
MS
1/* Verify that #pragma GCC diagnostic down the inlining stack suppresses
2 a warning that would otherwise be issued for inlined calls higher up
3 the inlining stack.
4 { dg-do compile }
5 { dg-options "-O2 -Wall -Wno-array-bounds" } */
6
7extern void* memset (void*, int, __SIZE_TYPE__);
8
9static void warn0 (int *p)
10{
11 memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" }
12}
13
14static void warn1 (int *p)
15{
16 warn0 (p + 1);
17}
18
19static void warn2 (int *p)
20{
21 warn1 (p + 1);
22}
23
24int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" }
25
26void warn3 (void)
27{
28 warn2 (a2 + 1);
29}
30
31
32// Verify suppression at the innermost frame of the inlining stack.
33
34static void ignore0 (int *p)
35{
36#pragma GCC diagnostic push
37#pragma GCC diagnostic ignored "-Wstringop-overflow"
38 memset (p, __LINE__, 3);
39#pragma GCC diagnostic pop
40}
41
42static void nowarn1_ignore0 (int *p)
43{
44 ignore0 (p + 1);
45}
46
47static void nowarn2_ignore0 (int *p)
48{
49 nowarn1_ignore0 (p + 1);
50}
51
52int b2[2];
53
54void nowarn3_ignore0 (void)
55{
56 nowarn2_ignore0 (b2 + 1);
57}
58
59
60// Verify suppression at the second innermost frame of the inlining stack.
61
62static void nowarn0_ignore1 (int *p)
63{
64 memset (p, __LINE__, 3);
65}
66
67static void ignore1 (int *p)
68{
69#pragma GCC diagnostic push
70#pragma GCC diagnostic ignored "-Wstringop-overflow"
71 nowarn0_ignore1 (p + 1);
72#pragma GCC diagnostic pop
73}
74
75void nowarn2_ignore1 (int *p)
76{
77 ignore1 (p + 1);
78}
79
80int c2[2];
81
82void nowarn3_ignore1 (void)
83{
84 nowarn2_ignore1 (c2 + 1);
85}
86
87
88// Verify suppression at the third innermost frame of the inlining stack.
89
90static void nowarn0_ignore2 (int *p)
91{
92 memset (p, __LINE__, 3);
93}
94
95static void nowarn1_ignore2 (int *p)
96{
97 nowarn0_ignore2 (p + 1);
98}
99
100static void ignore2 (int *p)
101{
102#pragma GCC diagnostic push
103#pragma GCC diagnostic ignored "-Wstringop-overflow"
104 nowarn1_ignore2 (p + 1);
105#pragma GCC diagnostic pop
106}
107
108int d2[2];
109
110void nowarn3_ignore2 (void)
111{
112 ignore2 (c2 + 1);
113}
114
115
116// Verify suppression at the outermost frame of the inlining stack.
117
118static void nowarn0_ignore3 (int *p)
119{
120 memset (p, __LINE__, 3);
121}
122
123static void nowarn1_ignore3 (int *p)
124{
125 nowarn0_ignore3 (p + 1);
126}
127
128static void nowarn2_ignore3 (int *p)
129{
130 nowarn1_ignore3 (p + 1);
131}
132
133int e2[2];
134
135void ignore3 (void)
136{
137#pragma GCC diagnostic push
138#pragma GCC diagnostic ignored "-Wstringop-overflow"
139 nowarn2_ignore3 (e2 + 1);
140#pragma GCC diagnostic pop
141}