diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-07-31 10:24:58 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-07-31 10:24:58 +0200 |
commit | 066bbc5721fbda2affe061fc4025a622bf30d5b5 (patch) | |
tree | f6856056cea7ca4d38b1682f111a0f33dddb0a52 /gcc/ubsan.c | |
parent | 0d1e5925e46184273f930aa45f1ec4f87752998b (diff) | |
download | gcc-066bbc5721fbda2affe061fc4025a622bf30d5b5.zip gcc-066bbc5721fbda2affe061fc4025a622bf30d5b5.tar.gz gcc-066bbc5721fbda2affe061fc4025a622bf30d5b5.tar.bz2 |
re PR sanitizer/81604 (Ubsan type reporting can be bogus in some cases)
PR sanitizer/81604
* ubsan.c (ubsan_type_descriptor): For UBSAN_PRINT_ARRAY don't
change type to the element type, instead add eltype variable and
use it where we are interested in the element type.
* c-c++-common/ubsan/pr81604.c: New test.
From-SVN: r250728
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r-- | gcc/ubsan.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c index cca3c2d..2580a58 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -402,6 +402,7 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle) /* We weren't able to determine the type name. */ tname = "<unknown>"; + tree eltype = type; if (pstyle == UBSAN_PRINT_POINTER) { pp_printf (&pretty_name, "'%s%s%s%s%s%s%s", @@ -452,12 +453,12 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle) pp_quote (&pretty_name); /* Save the tree with stripped types. */ - type = t; + eltype = t; } else pp_printf (&pretty_name, "'%s'", tname); - switch (TREE_CODE (type)) + switch (TREE_CODE (eltype)) { case BOOLEAN_TYPE: case ENUMERAL_TYPE: @@ -467,9 +468,9 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle) case REAL_TYPE: /* FIXME: libubsan right now only supports float, double and long double type formats. */ - if (TYPE_MODE (type) == TYPE_MODE (float_type_node) - || TYPE_MODE (type) == TYPE_MODE (double_type_node) - || TYPE_MODE (type) == TYPE_MODE (long_double_type_node)) + if (TYPE_MODE (eltype) == TYPE_MODE (float_type_node) + || TYPE_MODE (eltype) == TYPE_MODE (double_type_node) + || TYPE_MODE (eltype) == TYPE_MODE (long_double_type_node)) tkind = 0x0001; else tkind = 0xffff; @@ -478,7 +479,7 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style pstyle) tkind = 0xffff; break; } - tinfo = get_ubsan_type_info_for_type (type); + tinfo = get_ubsan_type_info_for_type (eltype); /* Create a new VAR_DECL of type descriptor. */ const char *tmp = pp_formatted_text (&pretty_name); |