[PATCH] integer overflow checking builtins in constant expressions

Jakub Jelinek jakub@redhat.com
Mon Jun 6 19:44:00 GMT 2016


Hi!

On Mon, Jun 06, 2016 at 02:36:17PM +0200, Jakub Jelinek wrote:
> 2016-06-06  Martin Sebor  <msebor@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/70507
> 	PR c/68120
> 	* builtins.def (BUILT_IN_ADD_OVERFLOW_P, BUILT_IN_SUB_OVERFLOW_P,
> 	BUILT_IN_MUL_OVERFLOW_P): New builtins.
> 	* builtins.c: Include gimple-fold.h.
> 	(fold_builtin_arith_overflow): Handle
> 	BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P.
> 	(fold_builtin_3): Likewise.
> 	* doc/extend.texi (Integer Overflow Builtins): Document
> 	__builtin_{add,sub,mul}_overflow_p.
> gcc/c/
> 	* c-typeck.c (convert_arguments): Don't promote last argument
> 	of BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P.
> gcc/cp/
> 	* constexpr.c: Include gimple-fold.h.
> 	(cxx_eval_internal_function): New function.
> 	(cxx_eval_call_expression): Call it.
> 	(potential_constant_expression_1): Handle integer arithmetic
> 	overflow built-ins.
> 	* tree.c (builtin_valid_in_constant_expr_p): Likewise.
> gcc/c-family/
> 	* c-common.c (check_builtin_function_arguments): Handle
> 	BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P.
> gcc/testsuite/
> 	* c-c++-common/builtin-arith-overflow-1.c: Add test cases.
> 	* c-c++-common/builtin-arith-overflow-2.c: New test.
> 	* g++.dg/cpp0x/constexpr-arith-overflow.C: New test.
> 	* g++.dg/cpp1y/constexpr-arith-overflow.C: New test.

Now successfully bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk?

	Jakub



More information about the Gcc-patches mailing list