Commit 6a4da643 by Marek Polacek Committed by Marek Polacek

c-ubsan.c (ubsan_instrument_shift): Use op1_utype for MINUS_EXPR instead of unsigned_type_node.

	* c-ubsan.c (ubsan_instrument_shift): Use op1_utype for MINUS_EXPR
	instead of unsigned_type_node.

	* c-c++-common/ubsan/shift-8.c: New test.

From-SVN: r218163
parent 9503ade2
2014-11-28 Marek Polacek <polacek@redhat.com>
* c-ubsan.c (ubsan_instrument_shift): Use op1_utype for MINUS_EXPR
instead of unsigned_type_node.
2014-11-28 Marek Polacek <polacek@redhat.com>
PR c/63862
* c-ubsan.c (ubsan_instrument_shift): Change the type of a MINUS_EXPR
to op1_utype.
......
......@@ -166,7 +166,7 @@ ubsan_instrument_shift (location_t loc, enum tree_code code,
&& !TYPE_UNSIGNED (TREE_TYPE (op0))
&& (cxx_dialect >= cxx11))
{
tree x = fold_build2 (MINUS_EXPR, unsigned_type_node, uprecm1,
tree x = fold_build2 (MINUS_EXPR, op1_utype, uprecm1,
fold_convert (op1_utype, op1));
tt = fold_convert_loc (loc, unsigned_type_for (type0), op0);
tt = fold_build2 (RSHIFT_EXPR, TREE_TYPE (tt), tt, x);
......
2014-11-28 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/shift-8.c: New test.
2014-11-28 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/64087
......
/* { dg-do compile } */
/* { dg-options "-fsanitize=undefined" } */
/* { dg-additional-options "-std=gnu11" { target c } } */
/* { dg-additional-options "-std=c++11" { target c++ } } */
signed char
fn1 (signed char x, unsigned long y)
{
return x << y;
}
short int
fn2 (short int x, unsigned long y)
{
return x << y;
}
int
fn3 (int x, unsigned long y)
{
return x << y;
}
long int
fn4 (long int x, unsigned long y)
{
return x << y;
}
long long int
fn5 (long long int x, unsigned long y)
{
return x << y;
}
signed char
fn6 (signed char x, unsigned long long y)
{
return x << y;
}
short int
fn7 (short int x, unsigned long long y)
{
return x << y;
}
int
fn8 (int x, unsigned long long y)
{
return x << y;
}
long int
fn9 (long int x, unsigned long long y)
{
return x << y;
}
long long int
fn10 (long long int x, unsigned long long y)
{
return x << y;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment