diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-06-24 13:04:29 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-06-24 13:04:29 +0200 |
commit | 00085092c5e78d076c4259e1f955ce1b98090624 (patch) | |
tree | a5be74dd1b38f05e395e46c9c539e60187f76173 /gcc/cp/call.c | |
parent | a86451b9b20415805e6316638c349cce86252893 (diff) | |
download | gcc-00085092c5e78d076c4259e1f955ce1b98090624.zip gcc-00085092c5e78d076c4259e1f955ce1b98090624.tar.gz gcc-00085092c5e78d076c4259e1f955ce1b98090624.tar.bz2 |
call.c (magic_varargs_p): Return 3 for __builtin_*_overflow_p.
* call.c (magic_varargs_p): Return 3 for __builtin_*_overflow_p.
(build_over_call): For magic == 3, do no conversion only on 3rd
argument.
* c-c++-common/torture/builtin-arith-overflow-p-19.c: Run for C++ too.
* g++.dg/ext/builtin-arith-overflow-2.C: New test.
From-SVN: r237755
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index b739fa0..d77092b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7132,7 +7132,8 @@ convert_for_arg_passing (tree type, tree val, tsubst_flags_t complain) which just decay_conversion or no conversions at all should be done. This is true for some builtins which don't act like normal functions. Return 2 if no conversions at all should be done, 1 if just - decay_conversion. */ + decay_conversion. Return 3 for special treatment of the 3rd argument + for __builtin_*_overflow_p. */ int magic_varargs_p (tree fn) @@ -7149,6 +7150,11 @@ magic_varargs_p (tree fn) case BUILT_IN_VA_START: return 1; + case BUILT_IN_ADD_OVERFLOW_P: + case BUILT_IN_SUB_OVERFLOW_P: + case BUILT_IN_MUL_OVERFLOW_P: + return 3; + default:; return lookup_attribute ("type generic", TYPE_ATTRIBUTES (TREE_TYPE (fn))) != 0; @@ -7606,14 +7612,14 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) for (; arg_index < vec_safe_length (args); ++arg_index) { tree a = (*args)[arg_index]; - if (magic == 2) + if ((magic == 3 && arg_index == 2) || magic == 2) { /* Do no conversions for certain magic varargs. */ a = mark_type_use (a); if (TREE_CODE (a) == FUNCTION_DECL && reject_gcc_builtin (a)) return error_mark_node; } - else if (magic == 1) + else if (magic != 0) /* For other magic varargs only do decay_conversion. */ a = decay_conversion (a, complain); else if (DECL_CONSTRUCTOR_P (fn) |