From 452ec2a5ec2e84bd6f469afb43b0928361d1710f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 29 Jan 2016 08:36:04 +0000 Subject: [PATCH] re PR middle-end/69537 (Incorrect -Wmaybe-uninitialized warning with enum variable) 2016-01-29 Richard Biener 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 | 6 ++++++ gcc/match.pd | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/uninit-21.c | 33 ++++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/uninit-21.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbdc5f7b92f..48c16d15af0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-01-29 Richard Biener + + PR middle-end/69537 + * match.pd: Allow all integral types when simplifying a + widening or sign-changing conversion. + 2016-01-28 Sebastian Pop * graphite-isl-ast-to-gimple.c (get_rename_from_scev): Revert assert diff --git a/gcc/match.pd b/gcc/match.pd index 5f282157012..63134114bdb 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -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 () diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8810beffe1..3c271847f7c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-01-29 Richard Biener + + PR middle-end/69537 + * gcc.dg/uninit-21.c: New testcase. + 2016-01-28 Uros Bizjak 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 index 00000000000..68e2c6dbe50 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-21.c @@ -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; +}