From: Richard Biener Date: Fri, 29 Jan 2016 08:36:04 +0000 (+0000) Subject: re PR middle-end/69537 (Incorrect -Wmaybe-uninitialized warning with enum variable) X-Git-Tag: basepoints/gcc-7~1230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=452ec2a5ec2e84bd6f469afb43b0928361d1710f;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbdc5f7b92f9..48c16d15af01 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 5f2821570127..63134114bdb6 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 d8810beffe1f..3c271847f7c7 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 000000000000..68e2c6dbe50e --- /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; +}