diff mbox

Fix up -Wmaybe-uninitialized (PR middle-end/59223)

Message ID 20140226195811.GF16545@redhat.com
State New
Headers show

Commit Message

Marek Polacek Feb. 26, 2014, 7:58 p.m. UTC
This fixes an oversight where we didn't run execute_late_warn_uninitialized
when only -Wmaybe-uninitialize was specified -- gate_warn_uninitialized
should take warn_maybe_uninitialized into account.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-02-26  Marek Polacek  <polacek@redhat.com>

	PR middle-end/59223
	* tree-ssa-uninit.c (gate_warn_uninitialized): Run the pass even for
	-Wmaybe-uninitialized.
testsuite/
	* c-c++-common/pr59223.c: New test.


	Marek

Comments

Richard Biener Feb. 26, 2014, 8:10 p.m. UTC | #1
On February 26, 2014 8:58:11 PM GMT+01:00, Marek Polacek <polacek@redhat.com> wrote:
>This fixes an oversight where we didn't run
>execute_late_warn_uninitialized
>when only -Wmaybe-uninitialize was specified -- gate_warn_uninitialized
>should take warn_maybe_uninitialized into account.
>
>Regtested/bootstrapped on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

>2014-02-26  Marek Polacek  <polacek@redhat.com>
>
>	PR middle-end/59223
>	* tree-ssa-uninit.c (gate_warn_uninitialized): Run the pass even for
>	-Wmaybe-uninitialized.
>testsuite/
>	* c-c++-common/pr59223.c: New test.
>
>diff --git gcc/testsuite/c-c++-common/pr59223.c
>gcc/testsuite/c-c++-common/pr59223.c
>index e69de29..471c062 100644
>--- gcc/testsuite/c-c++-common/pr59223.c
>+++ gcc/testsuite/c-c++-common/pr59223.c
>@@ -0,0 +1,13 @@
>+/* PR c/59223 */
>+/* { dg-do compile } */
>+/* { dg-options "-O2 -Wmaybe-uninitialized" } */
>+
>+int foo (int x)
>+{
>+  int y;
>+  if (x == 0)
>+    y = 1;
>+  else if (x == 1)
>+    y = 2;
>+  return y; /* { dg-warning "may be used uninitialized in this
>function" } */
>+}
>diff --git gcc/tree-ssa-uninit.c gcc/tree-ssa-uninit.c
>index d9b33b1..eee83f7 100644
>--- gcc/tree-ssa-uninit.c
>+++ gcc/tree-ssa-uninit.c
>@@ -2355,7 +2355,7 @@ execute_late_warn_uninitialized (void)
> static bool
> gate_warn_uninitialized (void)
> {
>-  return warn_uninitialized != 0;
>+  return warn_uninitialized || warn_maybe_uninitialized;
> }
> 
> namespace {
>
>	Marek
diff mbox

Patch

diff --git gcc/testsuite/c-c++-common/pr59223.c gcc/testsuite/c-c++-common/pr59223.c
index e69de29..471c062 100644
--- gcc/testsuite/c-c++-common/pr59223.c
+++ gcc/testsuite/c-c++-common/pr59223.c
@@ -0,0 +1,13 @@ 
+/* PR c/59223 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wmaybe-uninitialized" } */
+
+int foo (int x)
+{
+  int y;
+  if (x == 0)
+    y = 1;
+  else if (x == 1)
+    y = 2;
+  return y; /* { dg-warning "may be used uninitialized in this function" } */
+}
diff --git gcc/tree-ssa-uninit.c gcc/tree-ssa-uninit.c
index d9b33b1..eee83f7 100644
--- gcc/tree-ssa-uninit.c
+++ gcc/tree-ssa-uninit.c
@@ -2355,7 +2355,7 @@  execute_late_warn_uninitialized (void)
 static bool
 gate_warn_uninitialized (void)
 {
-  return warn_uninitialized != 0;
+  return warn_uninitialized || warn_maybe_uninitialized;
 }
 
 namespace {