| 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 |
|
| 7 |
extern void* memset (void*, int, __SIZE_TYPE__); |
| 8 |
|
| 9 |
static void warn0 (int *p) |
| 10 |
{ |
| 11 |
memset (p, __LINE__, 3); // { dg-warning "\\\[-Wstringop-overflow" } |
| 12 |
} |
| 13 |
|
| 14 |
static void warn1 (int *p) |
| 15 |
{ |
| 16 |
warn0 (p + 1); |
| 17 |
} |
| 18 |
|
| 19 |
static void warn2 (int *p) |
| 20 |
{ |
| 21 |
warn1 (p + 1); |
| 22 |
} |
| 23 |
|
| 24 |
int a2[2]; // { dg-message "at offset 12 into destination object 'a2' of size 8" } |
| 25 |
|
| 26 |
void warn3 (void) |
| 27 |
{ |
| 28 |
warn2 (a2 + 1); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
// Verify suppression at the innermost frame of the inlining stack. |
| 33 |
|
| 34 |
static 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 |
|
| 42 |
static void nowarn1_ignore0 (int *p) |
| 43 |
{ |
| 44 |
ignore0 (p + 1); |
| 45 |
} |
| 46 |
|
| 47 |
static void nowarn2_ignore0 (int *p) |
| 48 |
{ |
| 49 |
nowarn1_ignore0 (p + 1); |
| 50 |
} |
| 51 |
|
| 52 |
int b2[2]; |
| 53 |
|
| 54 |
void 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 |
|
| 62 |
static void nowarn0_ignore1 (int *p) |
| 63 |
{ |
| 64 |
memset (p, __LINE__, 3); |
| 65 |
} |
| 66 |
|
| 67 |
static 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 |
|
| 75 |
void nowarn2_ignore1 (int *p) |
| 76 |
{ |
| 77 |
ignore1 (p + 1); |
| 78 |
} |
| 79 |
|
| 80 |
int c2[2]; |
| 81 |
|
| 82 |
void 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 |
|
| 90 |
static void nowarn0_ignore2 (int *p) |
| 91 |
{ |
| 92 |
memset (p, __LINE__, 3); |
| 93 |
} |
| 94 |
|
| 95 |
static void nowarn1_ignore2 (int *p) |
| 96 |
{ |
| 97 |
nowarn0_ignore2 (p + 1); |
| 98 |
} |
| 99 |
|
| 100 |
static 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 |
|
| 108 |
int d2[2]; |
| 109 |
|
| 110 |
void nowarn3_ignore2 (void) |
| 111 |
{ |
| 112 |
ignore2 (c2 + 1); |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
// Verify suppression at the outermost frame of the inlining stack. |
| 117 |
|
| 118 |
static void nowarn0_ignore3 (int *p) |
| 119 |
{ |
| 120 |
memset (p, __LINE__, 3); |
| 121 |
} |
| 122 |
|
| 123 |
static void nowarn1_ignore3 (int *p) |
| 124 |
{ |
| 125 |
nowarn0_ignore3 (p + 1); |
| 126 |
} |
| 127 |
|
| 128 |
static void nowarn2_ignore3 (int *p) |
| 129 |
{ |
| 130 |
nowarn1_ignore3 (p + 1); |
| 131 |
} |
| 132 |
|
| 133 |
int e2[2]; |
| 134 |
|
| 135 |
void 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 |
} |