aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-03-31 10:39:24 -0600
committerMartin Sebor <msebor@redhat.com>2021-03-31 10:39:24 -0600
commit31199d95de1304e200554bbf98b2d8a6a7298bec (patch)
tree0e97bea5fcffcd591a8182446e43097cd7182d0b
parenta2531859bf5bf6cf1f29c0dca85fd26e80904a5d (diff)
downloadgcc-31199d95de1304e200554bbf98b2d8a6a7298bec.zip
gcc-31199d95de1304e200554bbf98b2d8a6a7298bec.tar.gz
gcc-31199d95de1304e200554bbf98b2d8a6a7298bec.tar.bz2
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.
-rw-r--r--gcc/testsuite/gcc.dg/uninit-pr65182.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/uninit-pr65182.c b/gcc/testsuite/gcc.dg/uninit-pr65182.c
new file mode 100644
index 0000000..45b538d
--- /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;
+}