diff options
author | Martin Sebor <msebor@redhat.com> | 2016-06-08 19:03:17 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-06-08 21:03:17 +0200 |
commit | 44a845ca0e592ca187fbab07ac9e055b20fb11cc (patch) | |
tree | 3a15f43474585970a2b22a98bf6ff1b46fcf075f /gcc/cp/tree.c | |
parent | 379aea728edb345f42b19dfade5529f8f9e8a6da (diff) | |
download | gcc-44a845ca0e592ca187fbab07ac9e055b20fb11cc.zip gcc-44a845ca0e592ca187fbab07ac9e055b20fb11cc.tar.gz gcc-44a845ca0e592ca187fbab07ac9e055b20fb11cc.tar.bz2 |
re PR c++/70507 (integer overflow builtins not constant expressions)
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): Handle
BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P.
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/ext/builtin-arith-overflow-1.C: New test.
* g++.dg/cpp0x/constexpr-arith-overflow.C: New test.
* g++.dg/cpp1y/constexpr-arith-overflow.C: New test.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r237238
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 04702ee..abda6e4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -352,6 +352,12 @@ builtin_valid_in_constant_expr_p (const_tree decl) case BUILT_IN_FUNCTION: case BUILT_IN_LINE: + /* The following built-ins are valid in constant expressions + when their arguments are. */ + case BUILT_IN_ADD_OVERFLOW_P: + case BUILT_IN_SUB_OVERFLOW_P: + case BUILT_IN_MUL_OVERFLOW_P: + /* These have constant results even if their operands are non-constant. */ case BUILT_IN_CONSTANT_P: |