libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / uninit-suppress_3.c
blob7bbe9edc605368db765b8b31b36d561168c6bff7
1 /* PR middle-end/98871 - Cannot silence -Wmaybe-uninitialized at declaration
2 site
3 { dg-do compile }
4 { dg-options "-O1 -Wall" } */
6 struct A
8 int x;
9 };
11 // Verify that suppression works at every inlining level.
13 static int f0 (int *x)
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
18 return ++*x;
20 #pragma GCC diagnostic pop
23 static int f1 (int *p, int n)
25 struct A a;
26 for (int i = 0; i < n; ++i) {
27 if (p[i] > 1) {
28 a = (struct A){p[i]};
32 return f0 (&a.x);
35 int f2 (void)
37 int a[] = { 1, 2, 3, 4 };
38 return f1 (a, 4);
42 static int g0 (int *x)
44 return ++*x;
47 static int g1 (int *p, int n)
49 #pragma GCC diagnostic push
50 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
52 struct A a;
53 for (int i = 0; i < n; ++i) {
54 if (p[i] > 1) {
55 a = (struct A){p[i]};
59 return g0 (&a.x);
61 #pragma GCC diagnostic pop
64 int g2 (void)
66 int a[] = { 1, 2, 3, 4, 5 };
67 return g1 (a, 5);
71 static int h0 (int *x)
73 return ++*x;
76 static int h1 (int *p, int n)
78 struct A a;
79 for (int i = 0; i < n; ++i) {
80 if (p[i] > 1) {
81 a = (struct A){p[i]};
85 return h0 (&a.x);
88 int h2 (void)
90 int a[] = { 1, 2, 3, 4, 5, 6 };
92 #pragma GCC diagnostic push
93 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
95 return h1 (a, 6);
97 #pragma GCC diagnostic pop