2017-12-02 Jakub Jelinek <jakub@redhat.com>
+ PR c++/81212
+ * tree-cfg.c (pass_warn_function_return::execute): Handle
+ __builtin_ubsan_handle_missing_return like __builtin_unreachable
+ with BUILTINS_LOCATION.
+
PR target/78643
PR target/80583
* expr.c (get_inner_reference): If DECL_MODE of a non-bitfield
2017-12-02 Jakub Jelinek <jakub@redhat.com>
+ PR c++/81212
+ * g++.dg/ubsan/pr81212.C: New test.
+ * g++.dg/ubsan/return-1.C: Add -Wno-return-type to dg-options.
+ * g++.dg/ubsan/return-2.C: Likewise.
+ * g++.dg/ubsan/return-7.C: Likewise.
+
PR target/78643
PR target/80583
* gcc.target/i386/pr80583.c: New test.
--- /dev/null
+// PR c++/81212
+// { dg-do compile }
+// { dg-options "-Wreturn-type -fsanitize=return" }
+
+struct S
+{
+ S (void *);
+ void *s;
+};
+
+S
+foo (bool x, void *y)
+{
+ if (x)
+ return S (y);
+} // { dg-warning "control reaches end of non-void function" }
// { dg-do run }
-// { dg-options "-fsanitize=return" }
+// { dg-options "-fsanitize=return -Wno-return-type" }
// { dg-shouldfail "ubsan" }
struct S { S (); ~S (); };
// { dg-do run }
-// { dg-options "-fsanitize=return -fno-sanitize-recover=return" }
+// { dg-options "-fsanitize=return -fno-sanitize-recover=return -Wno-return-type" }
struct S { S (); ~S (); };
// { dg-do run }
-// { dg-options "-fsanitize=undefined" }
+// { dg-options "-fsanitize=undefined -Wno-return-type" }
// { dg-shouldfail "ubsan" }
struct S { S (); ~S (); };
if (EDGE_COUNT (bb->succs) == 0)
{
gimple *last = last_stmt (bb);
+ const enum built_in_function ubsan_missing_ret
+ = BUILT_IN_UBSAN_HANDLE_MISSING_RETURN;
if (last
- && (LOCATION_LOCUS (gimple_location (last))
- == BUILTINS_LOCATION)
- && gimple_call_builtin_p (last, BUILT_IN_UNREACHABLE))
+ && ((LOCATION_LOCUS (gimple_location (last))
+ == BUILTINS_LOCATION
+ && gimple_call_builtin_p (last, BUILT_IN_UNREACHABLE))
+ || gimple_call_builtin_p (last, ubsan_missing_ret)))
{
gimple_stmt_iterator gsi = gsi_for_stmt (last);
gsi_prev_nondebug (&gsi);