diff options
author | Marek Polacek <polacek@redhat.com> | 2013-09-20 13:26:07 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2013-09-20 13:26:07 +0000 |
commit | a54300190578a207d66e7db8931eabe936261c14 (patch) | |
tree | 5dab4fb0ea472e947375cbd9033b08eac91e3add /gcc/ubsan.c | |
parent | 9fed7f3aa8f85b8658a081a0342b3a12d8107afa (diff) | |
download | gcc-a54300190578a207d66e7db8931eabe936261c14.zip gcc-a54300190578a207d66e7db8931eabe936261c14.tar.gz gcc-a54300190578a207d66e7db8931eabe936261c14.tar.bz2 |
re PR sanitizer/58413 (ubsan constant folding)
2013-09-20 Marek Polacek <polacek@redhat.com>
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.
From-SVN: r202776
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r-- | gcc/ubsan.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c index b8d40d5..6c6fea8 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -233,10 +233,9 @@ ubsan_source_location (location_t loc) static unsigned short get_ubsan_type_info_for_type (tree type) { - int prec = exact_log2 (TYPE_PRECISION (type)); - if (prec == -1) - error ("unexpected size of type %qT", type); - + gcc_assert (TYPE_SIZE (type) && host_integerp (TYPE_SIZE (type), 1)); + int prec = exact_log2 (tree_low_cst (TYPE_SIZE (type), 1)); + gcc_assert (prec != -1); return (prec << 1) | !TYPE_UNSIGNED (type); } |