re PR middle-end/89284 (gcc -fsanitize=undefined inhibits -Wuninitialized)
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Feb 2019 07:31:14 +0000 (08:31 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Feb 2019 07:31:14 +0000 (08:31 +0100)
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
gcc/passes.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ubsan/pr89284.c [new file with mode: 0644]

index 76720493dd6137caeeefd45ae721a73e26eadf69..b0cea85e47a7394c955a7556c7dde5619cb57d62 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89284
+       * passes.def: Swap pass_ubsan and pass_early_warn_uninitialized.
+
 2019-02-13  Ian Lance Taylor  <iant@golang.org>
 
        * optc-save-gen.awk: Set var_opt_hash for initial optimizations
index e9d9433abd836e22d713ad9abb9c9e7a8c16adb7..446a7c482767be8bbf17fbfdcaaa3b4a4f803555 100644 (file)
@@ -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 ()
index 67059b0c2c08cb756aa0e03ad444324c7e9a9083..c082cddf4a0dc5f3c62ca9b7356621c757d5b732 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89284
+       * gcc.dg/ubsan/pr89284.c: New test.
+
 2019-02-13  Ian Lance Taylor  <iant@golang.org>
 
        * 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 (file)
index 0000000..0d73e8f
--- /dev/null
@@ -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;
+}