[gcc r11-7932] PR middle-end/65182 - -Wuninitialized fails when pointer to variable later passed to function
Martin Sebor
msebor@gcc.gnu.org
Wed Mar 31 16:40:34 GMT 2021
https://gcc.gnu.org/g:31199d95de1304e200554bbf98b2d8a6a7298bec
commit r11-7932-g31199d95de1304e200554bbf98b2d8a6a7298bec
Author: Martin Sebor <msebor@redhat.com>
Date: Wed Mar 31 10:39:24 2021 -0600
PR middle-end/65182 - -Wuninitialized fails when pointer to variable later passed to function
gcc/testsuite:
PR middle-end/65182
* gcc.dg/uninit-pr65182.c: New test.
Diff:
---
gcc/testsuite/gcc.dg/uninit-pr65182.c | 44 +++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/uninit-pr65182.c b/gcc/testsuite/gcc.dg/uninit-pr65182.c
new file mode 100644
index 00000000000..45b538d1a2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr65182.c
@@ -0,0 +1,44 @@
+/* PR middle-end/65182 - -Wuninitialized fails when pointer to variable
+ later passed to function
+ { dg-do compile }
+ { dg-options "-O0 -Wall" } */
+
+void bar (int *a);
+
+int baz (void);
+
+__attribute__ ((noipa)) void foo_O0 (int *b)
+{
+ int a;
+
+ if (a) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ *b = 0;
+ return;
+ }
+
+ bar (&a);
+
+ a = baz ();
+
+ *b = a + 2;
+}
+
+#pragma GCC optimize ("2")
+
+__attribute__ ((noipa)) void foo_O2 (int *b)
+{
+ int a;
+
+ if (a) // { dg-warning "\\\[-Wuninitialized" }
+ {
+ *b = 0;
+ return;
+ }
+
+ bar (&a);
+
+ a = baz ();
+
+ *b = a + 3;
+}
More information about the Gcc-cvs
mailing list