File: pragma-diag-9.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (141 lines) | stat: -rw-r--r-- 2,420 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/* Verify that #pragma GCC diagnostic down the inlining stack suppresses
   a warning that would otherwise be issued for inlined calls higher up
   the inlining stack.
   { dg-do compile }
   { dg-options "-O2 -Wall -Wno-array-bounds" } */

extern void* memset (void*, int, __SIZE_TYPE__);

static void warn0 (int *p)
{
  memset (p, __LINE__, 3);    // { dg-warning "\\\[-Wstringop-overflow" }
}

static void warn1 (int *p)
{
  warn0 (p + 1);
}

static void warn2 (int *p)
{
  warn1 (p + 1);
}

int a2[2];                    // { dg-message "at offset 12 into destination object 'a2' of size 8" }

void warn3 (void)
{
  warn2 (a2 + 1);
}


// Verify suppression at the innermost frame of the inlining stack.

static void ignore0 (int *p)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
  memset (p, __LINE__, 3);
#pragma GCC diagnostic pop
}

static void nowarn1_ignore0 (int *p)
{
  ignore0 (p + 1);
}

static void nowarn2_ignore0 (int *p)
{
  nowarn1_ignore0 (p + 1);
}

int b2[2];

void nowarn3_ignore0 (void)
{
  nowarn2_ignore0 (b2 + 1);
}


// Verify suppression at the second innermost frame of the inlining stack.

static void nowarn0_ignore1 (int *p)
{
  memset (p, __LINE__, 3);
}

static void ignore1 (int *p)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
  nowarn0_ignore1 (p + 1);
#pragma GCC diagnostic pop
}

void nowarn2_ignore1 (int *p)
{
  ignore1 (p + 1);
}

int c2[2];

void nowarn3_ignore1 (void)
{
  nowarn2_ignore1 (c2 + 1);
}


// Verify suppression at the third innermost frame of the inlining stack.

static void nowarn0_ignore2 (int *p)
{
  memset (p, __LINE__, 3);
}

static void nowarn1_ignore2 (int *p)
{
  nowarn0_ignore2 (p + 1);
}

static void ignore2 (int *p)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
  nowarn1_ignore2 (p + 1);
#pragma GCC diagnostic pop
}

int d2[2];

void nowarn3_ignore2 (void)
{
  ignore2 (c2 + 1);
}


// Verify suppression at the outermost frame of the inlining stack.

static void nowarn0_ignore3 (int *p)
{
  memset (p, __LINE__, 3);
}

static void nowarn1_ignore3 (int *p)
{
  nowarn0_ignore3 (p + 1);
}

static void nowarn2_ignore3 (int *p)
{
  nowarn1_ignore3 (p + 1);
}

int e2[2];

void ignore3 (void)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
  nowarn2_ignore3 (e2 + 1);
#pragma GCC diagnostic pop
}