]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/69537 (Incorrect -Wmaybe-uninitialized warning with enum variable)
authorRichard Biener <rguenther@suse.de>
Fri, 29 Jan 2016 08:36:04 +0000 (08:36 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 29 Jan 2016 08:36:04 +0000 (08:36 +0000)
2016-01-29  Richard Biener  <rguenther@suse.de>

PR middle-end/69537
* match.pd: Allow all integral types when simplifying a
widening or sign-changing conversion.

* gcc.dg/uninit-21.c: New testcase.

From-SVN: r232968

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/uninit-21.c [new file with mode: 0644]

index bbdc5f7b92f9ecf72b0f02640a4131f930d82c3c..48c16d15af014bfe2945614c062e2c452e9ba56c 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-29  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/69537
+       * match.pd: Allow all integral types when simplifying a
+       widening or sign-changing conversion.
+
 2016-01-28  Sebastian Pop  <s.pop@samsung.com>
 
        * graphite-isl-ast-to-gimple.c (get_rename_from_scev): Revert assert
index 5f28215701270a1a400018ebb58489b33c558ddd..63134114bdb6b9e7aaaa5eb059c6099fca727d2d 100644 (file)
@@ -2121,7 +2121,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (for cmp (simple_comparison)
  (simplify
   (cmp (convert@0 @00) (convert?@1 @10))
-  (if (TREE_CODE (TREE_TYPE (@0)) == INTEGER_TYPE
+  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
        /* Disable this optimization if we're casting a function pointer
          type on targets that require function pointer canonicalization.  */
        && !(targetm.have_canonicalize_funcptr_for_compare ()
index d8810beffe1f704bca8d955261995bac23f50c65..3c271847f7c7b2162bef10f2b12b5acd172b6a62 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-29  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/69537
+       * gcc.dg/uninit-21.c: New testcase.
+
 2016-01-28  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/69459
diff --git a/gcc/testsuite/gcc.dg/uninit-21.c b/gcc/testsuite/gcc.dg/uninit-21.c
new file mode 100644 (file)
index 0000000..68e2c6d
--- /dev/null
@@ -0,0 +1,33 @@
+/* PR69537, spurious warning because of a missed optimization. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+enum clnt_stat {
+ RPC_SUCCESS=0,
+ RPC_CANTENCODEARGS=1,
+};
+int do_ypcall_tr ();
+static int
+yp_master (char **outname)
+{
+  // Replacing enum clnt_stat with int avoids the warning.
+  enum clnt_stat result;
+  result = do_ypcall_tr ();
+  if (result != 0)
+    return result;
+  *outname = __builtin_strdup ("foo");
+  return 0;
+}
+int
+yp_update (void)
+{
+  char *master;
+  int r;
+  if ((r = yp_master (&master)) != 0)
+    return r;
+  __builtin_free (master); /* { dg-bogus "uninitialized" } */
+  return 0;
+}