Paolo Bonzini - Re: PATCH RFC: -Wstrict-overflow (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

One suggestion I have is to define more functions to get rid of
fold_{,un}defer_overflow_warnings calls around code to compute the number of iterations. I think having to call different functions (mostly _warnv functions) is more maintainable than having to call
fold_defer_overflow_warnings all around.Another possibility, could be just to have wrappers around number_of_iterations_cond and number_of_iterations_exit, which would defer/undefer overflow warnings around the current code (of course, the current code could be renamed by adding a _1 to the name, or something like that).Anyway, my proposed functions would be:1) fold_comparison_warnv. It would do something like this:

fold_defer_overflow_warnings (); x = fold_binary (code, boolean_type_node, op0, op1); *warnmsg_p = fold_undefer_overflow_warnings ();

if (!x || TREE_CODE (x) != INTEGER_CST) return -1; else return integer_zerop (x) ? 0 : 1;

In number_of_iterations_cond, for example, there is a (safe) fold_binary_to_constant call, and a line like this: if (integer_zerop (fold_build2 (code, boolean_type_node, iv0->base, iv1->base)which could be written if (fold_comparison_warnv (code, iv0->base, iv1->base, &ignore) == 0)I didn't check if a fold_comparison function would be worthwhile.
2) fold_{unary,binary,ternary}_warnv, and/or fold_build{1,2,3}_warnv, doing something like this:

fold_defer_overflow_warnings (); x = fold_binary (code, type, op0, op1); *overflow_warning = fold_undefer_overflow_warnings (); return x;

These counterparts to fold_warnv would also be used in the number of iterations code.Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]