mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 19:03:59 +08:00
cp-gimplify.c (cp_maybe_instrument_return): Don't add __builtin_unreachable if -O0 or if -fsanitize=unreachable.
* cp-gimplify.c (cp_maybe_instrument_return): Don't add __builtin_unreachable if -O0 or if -fsanitize=unreachable. * g++.dg/missing-return.C: Add -O to dg-options. From-SVN: r255403
This commit is contained in:
parent
9896696391
commit
81e4859a97
@ -1,3 +1,8 @@
|
||||
2017-12-05 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* cp-gimplify.c (cp_maybe_instrument_return): Don't add
|
||||
__builtin_unreachable if -O0 or if -fsanitize=unreachable.
|
||||
|
||||
2017-12-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/83273 - constexpr if allows non-constant condition
|
||||
|
@ -1554,6 +1554,18 @@ cp_maybe_instrument_return (tree fndecl)
|
||||
|| !targetm.warn_func_return (fndecl))
|
||||
return;
|
||||
|
||||
if (!sanitize_flags_p (SANITIZE_RETURN, fndecl)
|
||||
/* Don't add __builtin_unreachable () if not optimizing, it will not
|
||||
improve any optimizations in that case, just break UB code.
|
||||
Don't add it if -fsanitize=unreachable -fno-sanitize=return either,
|
||||
UBSan covers this with ubsan_instrument_return above where sufficient
|
||||
information is provided, while the __builtin_unreachable () below
|
||||
if return sanitization is disabled will just result in hard to
|
||||
understand runtime error without location. */
|
||||
&& (!optimize
|
||||
|| sanitize_flags_p (SANITIZE_UNREACHABLE, fndecl)))
|
||||
return;
|
||||
|
||||
tree t = DECL_SAVED_TREE (fndecl);
|
||||
while (t)
|
||||
{
|
||||
|
@ -1,3 +1,7 @@
|
||||
2017-12-05 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* g++.dg/missing-return.C: Add -O to dg-options.
|
||||
|
||||
2017-12-04 Jeff Law <law@redhat.com>
|
||||
|
||||
PR tree-optimization/78496
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wreturn-type -fdump-tree-optimized" } */
|
||||
/* { dg-options "-Wreturn-type -fdump-tree-optimized -O" } */
|
||||
|
||||
int foo(int a)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user