From 31de5e4d91c8b348dd23ed2042983b9b057c882c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 14 Feb 2019 08:31:14 +0100 Subject: [PATCH] re PR middle-end/89284 (gcc -fsanitize=undefined inhibits -Wuninitialized) PR middle-end/89284 * passes.def: Swap pass_ubsan and pass_early_warn_uninitialized. * gcc.dg/ubsan/pr89284.c: New test. From-SVN: r268862 --- gcc/ChangeLog | 5 +++++ gcc/passes.def | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/ubsan/pr89284.c | 23 +++++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/ubsan/pr89284.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76720493dd6..b0cea85e47a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-02-14 Jakub Jelinek + + PR middle-end/89284 + * passes.def: Swap pass_ubsan and pass_early_warn_uninitialized. + 2019-02-13 Ian Lance Taylor * optc-save-gen.awk: Set var_opt_hash for initial optimizations diff --git a/gcc/passes.def b/gcc/passes.def index e9d9433abd8..446a7c48276 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -56,8 +56,8 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_build_ssa); NEXT_PASS (pass_warn_nonnull_compare); - NEXT_PASS (pass_ubsan); NEXT_PASS (pass_early_warn_uninitialized); + NEXT_PASS (pass_ubsan); NEXT_PASS (pass_nothrow); NEXT_PASS (pass_rebuild_cgraph_edges); POP_INSERT_PASSES () diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 67059b0c2c0..c082cddf4a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-14 Jakub Jelinek + + PR middle-end/89284 + * gcc.dg/ubsan/pr89284.c: New test. + 2019-02-13 Ian Lance Taylor * gcc.dg/func-attr-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/ubsan/pr89284.c b/gcc/testsuite/gcc.dg/ubsan/pr89284.c new file mode 100644 index 00000000000..0d73e8fa4a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/pr89284.c @@ -0,0 +1,23 @@ +/* PR middle-end/89284 */ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined -O0 -Wuninitialized" } */ + +struct A { _Bool a; int i; }; + +int +foo (void) +{ + struct A a; + if (a.i) /* { dg-warning "'a.i' is used uninitialized in this function" } */ + return 1; + return 0; +} + +int +bar (void) +{ + struct A a; + if (a.a) /* { dg-warning "'a.a' is used uninitialized in this function" } */ + return 1; + return 0; +} -- 2.30.2