re PR middle-end/63879 (ICE compiling Linux Kernel fs/ext3/namei.c with -fsanitize=undefined)
PR sanitizer/63879 * fold-const.c (negate_expr_p) <case NEGATE_EXPR>: Return !TYPE_OVERFLOW_SANITIZED. (fold_negate_expr) <case INTEGER_CST>: Fold when overflow does not trap and when overflow wraps, or when SANITIZE_SI_OVERFLOW is 0. * c-c++-common/ubsan/pr63879-1.c: New test. * c-c++-common/ubsan/pr63879-2.c: New test. From-SVN: r217766
This commit is contained in:
parent
877088b765
commit
3902bce049
5 changed files with 56 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-11-19 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/63879
|
||||
* fold-const.c (negate_expr_p) <case NEGATE_EXPR>: Return
|
||||
!TYPE_OVERFLOW_SANITIZED.
|
||||
(fold_negate_expr) <case INTEGER_CST>: Fold when overflow
|
||||
does not trap and when overflow wraps, or when SANITIZE_SI_OVERFLOW
|
||||
is 0.
|
||||
|
||||
2014-11-19 Ilya Tocar <ilya.tocar@intel.com>
|
||||
|
||||
* collect2.c (main): Don't call fatal_error before
|
||||
|
|
|
@ -408,9 +408,11 @@ negate_expr_p (tree t)
|
|||
&& TYPE_OVERFLOW_WRAPS (type));
|
||||
|
||||
case FIXED_CST:
|
||||
case NEGATE_EXPR:
|
||||
return true;
|
||||
|
||||
case NEGATE_EXPR:
|
||||
return !TYPE_OVERFLOW_SANITIZED (type);
|
||||
|
||||
case REAL_CST:
|
||||
/* We want to canonicalize to positive real constants. Pretend
|
||||
that only negative ones can be easily negated. */
|
||||
|
@ -555,7 +557,8 @@ fold_negate_expr (location_t loc, tree t)
|
|||
tem = fold_negate_const (t, type);
|
||||
if (TREE_OVERFLOW (tem) == TREE_OVERFLOW (t)
|
||||
|| (!TYPE_OVERFLOW_TRAPS (type)
|
||||
&& (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0))
|
||||
&& TYPE_OVERFLOW_WRAPS (type))
|
||||
|| (flag_sanitize & SANITIZE_SI_OVERFLOW) == 0)
|
||||
return tem;
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2014-11-19 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR sanitizer/63879
|
||||
* c-c++-common/ubsan/pr63879-1.c: New test.
|
||||
* c-c++-common/ubsan/pr63879-2.c: New test.
|
||||
|
||||
2014-11-19 Tom de Vries <tom@codesourcery.com>
|
||||
|
||||
PR tree-optimization/62167
|
||||
|
|
23
gcc/testsuite/c-c++-common/ubsan/pr63879-1.c
Normal file
23
gcc/testsuite/c-c++-common/ubsan/pr63879-1.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* PR sanitizer/63879 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-fsanitize=undefined" } */
|
||||
|
||||
struct A
|
||||
{
|
||||
int inode;
|
||||
} * a;
|
||||
int b, c;
|
||||
void
|
||||
fn1 ()
|
||||
{
|
||||
int d = 0;
|
||||
while (b)
|
||||
{
|
||||
if (a->inode)
|
||||
d++;
|
||||
a = 0;
|
||||
}
|
||||
c = d - 1;
|
||||
for (; c >= 0; c--)
|
||||
;
|
||||
}
|
13
gcc/testsuite/c-c++-common/ubsan/pr63879-2.c
Normal file
13
gcc/testsuite/c-c++-common/ubsan/pr63879-2.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* PR sanitizer/63879 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-fsanitize=undefined" } */
|
||||
|
||||
int a;
|
||||
void
|
||||
fn1 ()
|
||||
{
|
||||
int b = 2;
|
||||
for (; a;)
|
||||
while (b >= 0)
|
||||
b--;
|
||||
}
|
Loading…
Add table
Reference in a new issue