On Wed, Jun 25, 2014 at 11:12 AM, Bernd Edlinger
bernd.edlin...@hotmail.de wrote:
Hi,
this is part 2 of my patch, which uses the undefined behaviour, and emits a
strict overflow warning.
This fixes gnat.dg/opt37.adb again.
The diff is relative to part 1:
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01891.html
Boot-strapped and regression-tested on x86_64-linux-gnu.
OK for trunk?
+ /* For integer types, if A has a smaller type
+than T the result depends on the possible
+overflow in P + A.
+E.g. T=size_t, A=(unsigned)429497295, P0.
+However, if an overflow in P + A would cause
+undefined behavior, we can assume that there
+is no overflow. */
+ || (!POINTER_TYPE_P (TREE_TYPE (p))
+ INTEGRAL_TYPE_P (TREE_TYPE (a))
+ TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (a)))
it's clearer to simply test INTEGRAL_TYPE_P (TREE_TYPE (p)), that
way we know that A is also integral type. For consistency then
check TYPE_OVERFLOW_UNDEFINED on p as well.
+ if (issue_strict_overflow_warning
+ (WARN_STRICT_OVERFLOW_MISC)
+ TYPE_PRECISION (TREE_TYPE (rhs1))
+ TYPE_PRECISION (TREE_TYPE (a))
+ !POINTER_TYPE_P (TREE_TYPE (p)))
+ warning_at (gimple_location (stmt),
likewise here, check for INTEGRAL_TYPE_P (p).
Ok with that change.
Thanks,
Richard.
Thanks
Bernd.