Commit 38651b52 by Jakub Jelinek Committed by Jakub Jelinek

re PR sanitizer/81212 (-Wreturn-type is disabled when used together with -fsanitize=return)

	PR c++/81212
	* tree-cfg.c (pass_warn_function_return::execute): Handle
	__builtin_ubsan_handle_missing_return like __builtin_unreachable
	with BUILTINS_LOCATION.

	* 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.

From-SVN: r255354
parent e034c5c8
2017-12-02 Jakub Jelinek <jakub@redhat.com> 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/78643
PR target/80583 PR target/80583
* expr.c (get_inner_reference): If DECL_MODE of a non-bitfield * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield
2017-12-02 Jakub Jelinek <jakub@redhat.com> 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/78643
PR target/80583 PR target/80583
* gcc.target/i386/pr80583.c: New test. * gcc.target/i386/pr80583.c: New test.
......
// 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-do run }
// { dg-options "-fsanitize=return" } // { dg-options "-fsanitize=return -Wno-return-type" }
// { dg-shouldfail "ubsan" } // { dg-shouldfail "ubsan" }
struct S { S (); ~S (); }; struct S { S (); ~S (); };
......
// { dg-do run } // { 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 (); }; struct S { S (); ~S (); };
......
// { dg-do run } // { dg-do run }
// { dg-options "-fsanitize=undefined" } // { dg-options "-fsanitize=undefined -Wno-return-type" }
// { dg-shouldfail "ubsan" } // { dg-shouldfail "ubsan" }
struct S { S (); ~S (); }; struct S { S (); ~S (); };
......
...@@ -9151,10 +9151,13 @@ pass_warn_function_return::execute (function *fun) ...@@ -9151,10 +9151,13 @@ pass_warn_function_return::execute (function *fun)
if (EDGE_COUNT (bb->succs) == 0) if (EDGE_COUNT (bb->succs) == 0)
{ {
gimple *last = last_stmt (bb); gimple *last = last_stmt (bb);
const enum built_in_function ubsan_missing_ret
= BUILT_IN_UBSAN_HANDLE_MISSING_RETURN;
if (last if (last
&& (LOCATION_LOCUS (gimple_location (last)) && ((LOCATION_LOCUS (gimple_location (last))
== BUILTINS_LOCATION) == BUILTINS_LOCATION
&& gimple_call_builtin_p (last, BUILT_IN_UNREACHABLE)) && gimple_call_builtin_p (last, BUILT_IN_UNREACHABLE))
|| gimple_call_builtin_p (last, ubsan_missing_ret)))
{ {
gimple_stmt_iterator gsi = gsi_for_stmt (last); gimple_stmt_iterator gsi = gsi_for_stmt (last);
gsi_prev_nondebug (&gsi); gsi_prev_nondebug (&gsi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment