mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-23 15:39:46 +08:00
c++: properly initialize UBSAN built-ins
PR c++/106062 gcc/ChangeLog: * ubsan.cc (sanitize_unreachable_fn): Change order of calls in order to initialize UBSAN built-ins. gcc/testsuite/ChangeLog: * gfortran.dg/ubsan/pr106062.f90: New test.
This commit is contained in:
parent
c01fe6729e
commit
8a15cd3396
11
gcc/testsuite/gfortran.dg/ubsan/pr106062.f90
Normal file
11
gcc/testsuite/gfortran.dg/ubsan/pr106062.f90
Normal file
@ -0,0 +1,11 @@
|
||||
! PR c++/106062
|
||||
! { dg-do compile }
|
||||
! { dg-options "-O2 -fsanitize=undefined" }
|
||||
|
||||
call test (reshape ((/ 'a', 'b', 'c', 'd' /), (/ 2, 2 /)))
|
||||
contains
|
||||
subroutine test (a)
|
||||
character (*), dimension (:, :) :: a
|
||||
if (len (a) .ne. 1) STOP
|
||||
end
|
||||
end
|
@ -654,9 +654,10 @@ sanitize_unreachable_fn (tree *data, location_t loc)
|
||||
}
|
||||
else if (san)
|
||||
{
|
||||
fn = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
|
||||
/* Call ubsan_create_data first as it initializes SANITIZER built-ins. */
|
||||
*data = ubsan_create_data ("__ubsan_unreachable_data", 1, &loc,
|
||||
NULL_TREE, NULL_TREE);
|
||||
fn = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
|
||||
*data = build_fold_addr_expr_loc (loc, *data);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user