From 0a508bb66b6056dd7a7cd7a689daa1b1dfff6863 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 22 Nov 2013 21:07:31 +0100 Subject: ubsan.c (ubsan_source_location): Don't crash on unknown locations. * ubsan.c (ubsan_source_location): Don't crash on unknown locations. (ubsan_pass): Ignore clobber stmts. * sanitizer.def (BUILT_IN_UBSAN_HANDLE_MISSING_RETURN): New built-in. * opts.c (common_handle_option): Add -fsanitize=return. * flag-types.h (enum sanitize_code): Add SANITIZE_RETURN and or it into SANITIZE_UNDEFINED. c-family/ * c-ubsan.h (ubsan_instrument_return): New prototype. * c-ubsan.c (ubsan_instrument_return): New function. cp/ * cp-gimplify.c: Include target.h and c-family/c-ubsan.h. (cp_ubsan_maybe_instrument_return): New function. (cp_genericize): Call it if -fsanitize=return. testsuite/ * g++.dg/ubsan/return-1.C: New test. * g++.dg/ubsan/return-2.C: New test. From-SVN: r205283 --- gcc/ubsan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/ubsan.c') diff --git a/gcc/ubsan.c b/gcc/ubsan.c index 5effd55..f2b66bf 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -229,8 +229,8 @@ ubsan_source_location (location_t loc) xloc = expand_location (loc); /* Fill in the values from LOC. */ - size_t len = strlen (xloc.file); - tree str = build_string (len + 1, xloc.file); + size_t len = xloc.file ? strlen (xloc.file) : 0; + tree str = build_string (len + 1, xloc.file ? xloc.file : ""); TREE_TYPE (str) = build_array_type (char_type_node, build_index_type (size_int (len))); TREE_READONLY (str) = 1; @@ -644,7 +644,7 @@ ubsan_pass (void) { struct walk_stmt_info wi; gimple stmt = gsi_stmt (gsi); - if (is_gimple_debug (stmt)) + if (is_gimple_debug (stmt) || gimple_clobber_p (stmt)) { gsi_next (&gsi); continue; -- cgit v1.1