[gcc r11-7839] New test for PR tree-optimization/44547 - -Wuninitialized reports false warning in nested switch sta

Martin Sebor msebor@gcc.gnu.org
Thu Mar 25 21:33:35 GMT 2021


https://gcc.gnu.org/g:1b229a305091f0a9c64e5be3c1af5ef62b75e3cb

commit r11-7839-g1b229a305091f0a9c64e5be3c1af5ef62b75e3cb
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Mar 25 15:31:46 2021 -0600

    New test for PR tree-optimization/44547 - -Wuninitialized reports false warning in nested switch statements.
    
    gcc/testsuite/ChangeLog:
            * gcc.dg/uninit-pr44547.c: New.

Diff:
---
 gcc/testsuite/gcc.dg/uninit-pr44547.c | 61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/uninit-pr44547.c b/gcc/testsuite/gcc.dg/uninit-pr44547.c
new file mode 100644
index 00000000000..ee1035ad7b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-pr44547.c
@@ -0,0 +1,61 @@
+/* PR tree-optimization/44547 - -Wuninitialized reports false warning
+   in nested switch statements
+   { dg-do compile }
+   { dg-options "-O1 -Wall" } */
+
+__attribute__ ((noipa)) int test_O1 (int argc)
+{
+  switch( argc )
+    {
+    case 1:
+    case 2:
+    case 4:
+      {
+	int n;
+	switch( argc )
+	  {
+	  case 1:
+	  case 2:
+	  case 4:
+	    n = argc;
+	    break;
+	  }
+
+	return n;
+
+	break;
+      }
+    }
+
+  return 0;
+}
+
+
+#pragma GCC optimize ("2")
+
+__attribute__ ((noipa)) int test_O2 (int argc)
+{
+  switch( argc )
+    {
+    case 1:
+    case 2:
+    case 4:
+      {
+	int n;
+	switch( argc )
+	  {
+	  case 1:
+	  case 2:
+	  case 4:
+	    n = argc;
+	    break;
+	  }
+
+	return n;
+
+	break;
+      }
+    }
+
+  return 0;
+}


More information about the Gcc-cvs mailing list