* [PATCH] Fix PR69537
@ 2016-01-28 14:05 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2016-01-28 14:05 UTC (permalink / raw)
To: gcc-patches
I am fixing the missed optimization / bogus warning with relaxing
the guard around "old" fold_{widened,sing_changing}_comparison
which is now in match.pd.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
I'm curious if any issues with casts-to-BOOLEAN_TYPE show up
in our testsuite (and wonder how we didn't bother to then test
also for casts-from-BOOLEAN_TYPE).
Richard.
2016-01-28 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.
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 232925)
+++ gcc/match.pd (working copy)
@@ -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: gcc/testsuite/gcc.dg/uninit-21.c
===================================================================
--- gcc/testsuite/gcc.dg/uninit-21.c (revision 0)
+++ gcc/testsuite/gcc.dg/uninit-21.c (working copy)
@@ -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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-28 14:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28 14:05 [PATCH] Fix PR69537 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).