summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/c-c++-common/ubsan
Commit message (Collapse)AuthorAgeFilesLines
* PR sanitizer/60636jakub2014-03-261-0/+15
| | | | | | | | | * ubsan.c (instrument_si_overflow): Instrument ABS_EXPR. * c-c++-common/ubsan/pr60636.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208841 138bc75d-0d04-0410-961f-82ee72b054a4
* * c-c++-common/ubsan/div-by-zero-4.c: Don't include limits.h. Definempolacek2014-03-2416-2/+117
| | | | | | | | | | | | | | | | | | | | | | | | | INT_MIN. * c-c++-common/ubsan/overflow-1.c: Check for unwanted output. * c-c++-common/ubsan/overflow-add-1.c: Likewise. * c-c++-common/ubsan/overflow-mul-1.c: Likewise. * c-c++-common/ubsan/overflow-mul-3.c: Likewise. * c-c++-common/ubsan/overflow-negate-2.c: Likewise. * c-c++-common/ubsan/overflow-sub-1.c: Likewise. * c-c++-common/ubsan/pr59503.c: Likewise. * c-c++-common/ubsan/pr60613-1.c: Likewise. * c-c++-common/ubsan/save-expr-1.c: Likewise. * c-c++-common/ubsan/shift-3.c: Likewise. * c-c++-common/ubsan/shift-6.c: Likewise. * c-c++-common/ubsan/undefined-1.c: Likewise. * c-c++-common/ubsan/vla-2.c: Likewise. * c-c++-common/ubsan/vla-3.c: Likewise. * c-c++-common/ubsan/vla-4.c: Likewise. * g++.dg/ubsan/cxx11-shift-1.C: Likewise. * g++.dg/ubsan/return-2.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208787 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/60613jakub2014-03-222-0/+69
| | | | | | | | | | | * internal-fn.c (ubsan_expand_si_overflow_addsub_check): For code == MINUS_EXPR, never swap op0 with op1. * c-c++-common/ubsan/pr60613-1.c: New test. * c-c++-common/ubsan/pr60613-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208766 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/60535jakub2014-03-1828-28/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ubsan.c (ubsan_type_descriptor, ubsan_create_data): Call varpool_finalize_decl instead of rest_of_decl_compilation. lto/ * lto-lang.c (lto_init): Add NAME_TYPE for int128_integer_type_node and complex_{float,{,long_}double}_type_node. testsuite/ * c-c++-common/ubsan/null-1.c: Don't skip if -flto. * c-c++-common/ubsan/null-2.c: Likewise. * c-c++-common/ubsan/null-3.c: Likewise. * c-c++-common/ubsan/null-4.c: Likewise. * c-c++-common/ubsan/null-5.c: Likewise. * c-c++-common/ubsan/null-6.c: Likewise. * c-c++-common/ubsan/null-7.c: Likewise. * c-c++-common/ubsan/null-8.c: Likewise. * c-c++-common/ubsan/null-9.c: Likewise. * c-c++-common/ubsan/null-10.c: Likewise. * c-c++-common/ubsan/null-11.c: Likewise. * c-c++-common/ubsan/overflow-1.c: Likewise. * c-c++-common/ubsan/overflow-2.c: Likewise. * c-c++-common/ubsan/overflow-add-1.c: Likewise. * c-c++-common/ubsan/overflow-add-2.c: Likewise. * c-c++-common/ubsan/overflow-int128.c: Likewise. * c-c++-common/ubsan/overflow-mul-1.c: Likewise. * c-c++-common/ubsan/overflow-mul-2.c: Likewise. * c-c++-common/ubsan/overflow-mul-3.c: Likewise. * c-c++-common/ubsan/overflow-mul-4.c: Likewise. * c-c++-common/ubsan/overflow-negate-1.c: Likewise. * c-c++-common/ubsan/overflow-negate-2.c: Likewise. * c-c++-common/ubsan/overflow-sub-1.c: Likewise. * c-c++-common/ubsan/overflow-sub-2.c: Likewise. * c-c++-common/ubsan/pr59333.c: Likewise. * c-c++-common/ubsan/pr59503.c: Likewise. * c-c++-common/ubsan/pr59667.c: Likewise. * c-c++-common/ubsan/undefined-1.c: Likewise. * g++.dg/ubsan/pr59250.C: Likewise. * g++.dg/ubsan/pr59306.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208651 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-02-14 Bernd Edlinger <bernd.edlinger@hotmail.de>edlinger2014-02-141-1/+1
| | | | | | | * c-c++-common/ubsan/overflow-negate-2.c (main): Use signed char. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207786 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59667mpolacek2014-01-081-0/+15
| | | | | | | | | * ubsan.c (ubsan_type_descriptor): Call strip_array_types on type2. testsuite/ * c-c++-common/ubsan/pr59667.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206423 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-12-27 Yury Gribov <y.gribov@samsung.com>ygribov2013-12-2714-15/+15
| | | | | | | | | | | | | | | | | | | | | PR target/59585 * c-c++-common/ubsan/div-by-zero-1.c: Fixed pattern. * c-c++-common/ubsan/div-by-zero-2.c: Likewise. * c-c++-common/ubsan/div-by-zero-3.c: Likewise. * c-c++-common/ubsan/load-bool-enum.c: Likewise. * c-c++-common/ubsan/overflow-add-2.c: Likewise. * c-c++-common/ubsan/overflow-mul-2.c: Likewise. * c-c++-common/ubsan/overflow-mul-4.c: Likewise. * c-c++-common/ubsan/overflow-negate-1.c: Likewise. * c-c++-common/ubsan/overflow-sub-2.c: Likewise. * c-c++-common/ubsan/pr59333.c: Likewise. * c-c++-common/ubsan/shift-1.c: Likewise. * c-c++-common/ubsan/shift-2.c: Likewise. * c-c++-common/ubsan/shift-4.c: Likewise. * c-c++-common/ubsan/vla-1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206219 138bc75d-0d04-0410-961f-82ee72b054a4
* * ubsan.c: Include tree-ssanames.h, asan.h and gimplify-me.h.jakub2013-12-201-0/+29
| | | | | | | | | | | | | | | | | | | | | | | (ubsan_type_descriptor): Handle BOOLEAN_TYPE and ENUMERAL_TYPE like INTEGER_TYPE. (instrument_bool_enum_load): New function. (ubsan_pass): Call it. (gate_ubsan): Also enable for SANITIZE_BOOL or SANITIZE_ENUM. * asan.c (create_cond_insert_point): No longer static. * asan.h (create_cond_insert_point): Declare. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_LOAD_INVALID_VALUE): New built-in. * opts.c (common_handle_option): Handle -fsanitize=bool and -fsanitize=enum. * builtins.c (fold_builtin_memory_op): When sanitizing bool and enum loads, don't use enum or bool types for memcpy folding. * flag-types.h (SANITIZE_BOOL, SANITIZE_ENUM): New. (SANITIZE_UNDEFINED): Or these in. * c-c++-common/ubsan/load-bool-enum.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206143 138bc75d-0d04-0410-961f-82ee72b054a4
* Add __int128 test.mpolacek2013-12-171-0/+48
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206065 138bc75d-0d04-0410-961f-82ee72b054a4
* * predict.h (PROB_LIKELY): Fix the value.jakub2013-12-162-0/+125
| | | | | | | | | | | | * internal-fn.c (ubsan_expand_si_overflow_mul_check): Add support for overflow checking for modes without 2xwider supported mode, if the mode has 2xnarrower mode. * c-c++-common/ubsan/overflow-mul-3.c: New test. * c-c++-common/ubsan/overflow-mul-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206026 138bc75d-0d04-0410-961f-82ee72b054a4
* More overflow-negate-* testing.mpolacek2013-12-142-3/+67
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205992 138bc75d-0d04-0410-961f-82ee72b054a4
* More tests for ubsan.mpolacek2013-12-142-0/+271
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205985 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59503mpolacek2013-12-141-0/+14
| | | | | | | | | | | * internal-fn.c (ubsan_expand_si_overflow_addsub_check): Call expand_binop with correct optab depending on code. testsuite/ * c-c++-common/ubsan/pr59503.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205984 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59333mpolacek2013-12-052-0/+29
| | | | | | | | | | | | | | | | | | | | | PR sanitizer/59397 * ubsan.c: Include rtl.h and expr.h. (ubsan_encode_value): Add new parameter. If expanding, assign a stack slot for DECL_RTL of the temporary and call expand_assignment. Handle BOOLEAN_TYPE and ENUMERAL_TYPE. (ubsan_build_overflow_builtin): Adjust ubsan_encode_value call. * ubsan.h (ubsan_encode_value): Adjust declaration. * internal-fn.c (ubsan_expand_si_overflow_addsub_check): Move ubsan_build_overflow_builtin above expand_normal call. Surround this call with push_temp_slots and pop_temp_slots. (ubsan_expand_si_overflow_neg_check): Likewise. (ubsan_expand_si_overflow_mul_check): Likewise. testsuite/ * c-c++-common/ubsan/pr59333.c: New test. * c-c++-common/ubsan/pr59397.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205714 138bc75d-0d04-0410-961f-82ee72b054a4
* Implement -fsanitize=signed-integer-overflow.mpolacek2013-12-047-0/+328
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205684 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-12-02 Marek Polacek <polacek@redhat.com>mpolacek2013-12-021-13/+84
| | | | | | | | | | testsuite/ * c-c++-common/ubsan/vla-1.c: Split the tests into individual functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205590 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59331mpolacek2013-11-293-3/+3
| | | | | | | | | | | | | | | | | cp/ * decl.c (compute_array_index_type): Don't build COMPOUND_EXPR for instrumentation. testsuite/ * g++.dg/ubsan/pr59331.C: New test. * g++.dg/ubsan/cxx1y-vla.C: Enable -Wall -Wno-unused-variable. Disable the -w option. * c-c++-common/ubsan/vla-1.c: Likewise. * c-c++-common/ubsan/vla-2.c: Likewise. * c-c++-common/ubsan/vla-3.c: Don't use the -w option. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205544 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-11-27 Marek Polacek <polacek@redhat.com>mpolacek2013-11-271-0/+26
| | | | | | | | | | | * ubsan.c (ubsan_type_descriptor): If varpool_get_node returns NULL for a decl, recreate that decl. Save into the hash table VAR_DECLs rather than ADDR_EXPRs. testsuite/ * c-c++-common/ubsan/undefined-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205433 138bc75d-0d04-0410-961f-82ee72b054a4
* config/mpolacek2013-11-1913-9/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Add -ldl. gcc/c-family/ * c-ubsan.c (ubsan_instrument_division): Adjust ubsan_create_data call. (ubsan_instrument_shift): Likewise. (ubsan_instrument_vla): Likewise. gcc/ * opts.c (common_handle_option): Add -fsanitize=null option. Turn off -fdelete-null-pointer-checks option when doing the NULL pointer checking. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH): Add. * tree-pass.h (make_pass_ubsan): Declare. (make_pass_sanopt): Declare. * timevar.def (TV_TREE_UBSAN): New timevar. * passes.def: Add pass_sanopt and pass_ubsan. * ubsan.h (ubsan_null_ckind): New enum. (ubsan_mismatch_data): New struct. (ubsan_expand_null_ifn): Declare. (ubsan_create_data): Adjust declaration. (ubsan_type_descriptor): Likewise. * asan.c: Include "ubsan.h". (pass_data_sanopt): New pass. (execute_sanopt): New function. (gate_sanopt): Likewise. (make_pass_sanopt): Likewise. (class pass_sanopt): New class. * ubsan.c: Include tree-pass.h, gimple-ssa.h, gimple-walk.h, gimple-iterator.h and cfgloop.h. (PROB_VERY_UNLIKELY): Define. (tree_type_map_hash): New function. (ubsan_type_descriptor): Add new parameter. Improve type name generation. (ubsan_create_data): Add new parameter. Add pointer data into ubsan structure. (ubsan_expand_null_ifn): New function. (instrument_member_call): Likewise. (instrument_mem_ref): Likewise. (instrument_null): Likewise. (ubsan_pass): Likewise. (gate_ubsan): Likewise. (make_pass_ubsan): Likewise. (ubsan_instrument_unreachable): Adjust ubsan_create_data call. (class pass_ubsan): New class. (pass_data_ubsan): New pass. * flag-types.h (enum sanitize_code): Add SANITIZE_NULL. * internal-fn.c (expand_UBSAN_NULL): New function. * cgraphunit.c (varpool_finalize_decl): Call varpool_assemble_decl even when !flag_toplevel_reorder. * internal-fn.def (UBSAN_NULL): New. gcc/testsuite/ * c-c++-common/ubsan/null-1.c: New test. * c-c++-common/ubsan/null-2.c: New test. * c-c++-common/ubsan/null-3.c: New test. * c-c++-common/ubsan/null-4.c: New test. * c-c++-common/ubsan/null-5.c: New test. * c-c++-common/ubsan/null-6.c: New test. * c-c++-common/ubsan/null-7.c: New test. * c-c++-common/ubsan/null-8.c: New test. * c-c++-common/ubsan/null-9.c: New test. * c-c++-common/ubsan/null-10.c: New test. * c-c++-common/ubsan/null-11.c: New test. * gcc.dg/ubsan/c99-shift-2.c: Adjust dg-output. * c-c++-common/ubsan/shift-1.c: Likewise. * c-c++-common/ubsan/div-by-zero-3.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205021 138bc75d-0d04-0410-961f-82ee72b054a4
* Implement -fsanitize=vla-bound.mpolacek2013-11-034-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * opts.c (common_handle_option): Handle vla-bound. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_VLA_BOUND_NOT_POSITIVE): Define. * flag-types.h (enum sanitize_code): Add SANITIZE_VLA. * asan.c (initialize_sanitizer_builtins): Build BT_FN_VOID_PTR_PTR. c-family/ * c-ubsan.c: Don't include hash-table.h. (ubsan_instrument_vla): New function. * c-ubsan.h: Declare it. cp/ * decl.c (cp_finish_decl): Move C++1y bounds checking... (compute_array_index_type): ...here. Add VLA instrumentation. Call stabilize_vla_size. (grokdeclarator): Don't call stabilize_vla_size here. c/ * c-decl.c (grokdeclarator): Add VLA instrumentation. testsuite/ * g++.dg/ubsan/cxx1y-vla.C: New test. * c-c++-common/ubsan/vla-3.c: New test. * c-c++-common/ubsan/vla-2.c: New test. * c-c++-common/ubsan/vla-4.c: New test. * c-c++-common/ubsan/vla-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204334 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/58413mpolacek2013-09-253-0/+71
| | | | | | | | | | | | | | | | | c-family/ * c-ubsan.c (ubsan_instrument_shift): Don't instrument an expression if we can prove it is correct. (ubsan_instrument_division): Likewise. Remove unnecessary check. testsuite/ * c-c++-common/ubsan/shift-5.c: New test. * c-c++-common/ubsan/shift-6.c: New test. * c-c++-common/ubsan/div-by-zero-5.c: New test. * gcc.dg/ubsan/c-shift-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202886 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-09-20 Marek Polacek <polacek@redhat.com>mpolacek2013-09-201-0/+14
| | | | | | | | | | | | | PR sanitizer/58413 * ubsan.c (get_ubsan_type_info_for_type): Use TYPE_SIZE instead of TYPE_PRECISION. Add asserts. testsuite/ * c-c++-common/ubsan/shift-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202776 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-09-18 Marek Polacek <polacek@redhat.com>mpolacek2013-09-183-0/+40
| | | | | | | | | | | | | | | | | | | | | | PR sanitize/58443 cp/ * typeck.c (cp_build_binary_op): Properly honor -fsanitize options. Remove unnecessary check. c/ * c-typeck.c (build_binary_op): Properly honor -fsanitize options. Remove unnecessary check. testsuite/ * g++.dg/ubsan/div-by-zero-1.C: Use the integer-divide-by-zero option instead of the shift option. * c-c++-common/ubsan/pr58443-1.c: New test. * c-c++-common/ubsan/pr58443-3.c: New test. * c-c++-common/ubsan/pr58443-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202701 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-09-18 Marek Polacek <polacek@redhat.com>mpolacek2013-09-181-0/+33
| | | | | | | | | | | PR sanitizer/58411 * doc/extend.texi: Document no_sanitize_undefined attribute. * builtins.c (fold_builtin_0): Don't sanitize function if it has the no_sanitize_undefined attribute. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202682 138bc75d-0d04-0410-961f-82ee72b054a4
* Merge ubsan into trunk.mpolacek2013-08-3015-0/+254
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202113 138bc75d-0d04-0410-961f-82ee72b054a4
OpenPOWER on IntegriCloud