diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-12-21 23:15:59 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-12-21 23:15:59 +0100 |
commit | 0dba79602a7e3fb62bebee58b2cd7c24115b4faf (patch) | |
tree | 5cf6b631ea6cd0b3f5aca6c10361d66c4b8c572b /gcc/builtins.c | |
parent | bc2a38dff859fcd1ec0aedd8c7d0fb748f2dbede (diff) | |
download | gcc-0dba79602a7e3fb62bebee58b2cd7c24115b4faf.zip gcc-0dba79602a7e3fb62bebee58b2cd7c24115b4faf.tar.gz gcc-0dba79602a7e3fb62bebee58b2cd7c24115b4faf.tar.bz2 |
re PR bootstrap/78817 (stage2 bootstrap failure in vec.h:1613:5: error: argument 1 null where non-null expected after r243661)
PR bootstrap/78817
* tree-pass.h (make_pass_post_ipa_warn): Declare.
* builtins.c (validate_arglist): Adjust get_nonnull_args call.
Check for NULL pointer argument to nonnull arg here.
(validate_arg): Revert 2016-12-14 changes.
* calls.h (get_nonnull_args): Remove declaration.
* tree-ssa-ccp.c: Include diagnostic-core.h.
(pass_data_post_ipa_warn): New variable.
(pass_post_ipa_warn): New class.
(pass_post_ipa_warn::execute): New method.
(make_pass_post_ipa_warn): New function.
* tree.h (get_nonnull_args): Declare.
* tree.c (get_nonnull_args): New function.
* calls.c (maybe_warn_null_arg): Removed.
(maybe_warn_null_arg): Removed.
(initialize_argument_information): Revert 2016-12-14 changes.
* passes.def: Add pass_post_ipa_warn after first ccp after IPA.
c-family/
* c-common.c (struct nonnull_arg_ctx): New type.
(check_function_nonnull): Return bool instead of void. Use
nonnull_arg_ctx as context rather than just location_t.
(check_nonnull_arg): Adjust for the new context type, set
warned_p to true if a warning has been diagnosed.
(check_function_arguments): Return bool instead of void.
* c-common.h (check_function_arguments): Adjust prototype.
c/
* c-typeck.c (build_function_call_vec): If check_function_arguments
returns true, set TREE_NO_WARNING on CALL_EXPR.
cp/
* typeck.c (cp_build_function_call_vec): If check_function_arguments
returns true, set TREE_NO_WARNING on CALL_EXPR.
* call.c (build_over_call): Likewise.
From-SVN: r243874
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index ca038cd..216d926 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -147,7 +147,7 @@ static tree fold_builtin_classify_type (tree); static tree fold_builtin_strlen (location_t, tree, tree); static tree fold_builtin_inf (location_t, tree, int); static tree rewrite_call_expr (location_t, tree, int, tree, int, ...); -static bool validate_arg (const_tree, enum tree_code code, bool = false); +static bool validate_arg (const_tree, enum tree_code code); static rtx expand_builtin_fabs (tree, rtx, rtx); static rtx expand_builtin_signbit (tree, rtx); static tree fold_builtin_memcmp (location_t, tree, tree, tree); @@ -1050,12 +1050,12 @@ validate_arglist (const_tree callexpr, ...) init_const_call_expr_arg_iterator (callexpr, &iter); /* Get a bitmap of pointer argument numbers declared attribute nonnull. */ - bitmap argmap = get_nonnull_args (callexpr); + tree fn = CALL_EXPR_FN (callexpr); + bitmap argmap = get_nonnull_args (TREE_TYPE (TREE_TYPE (fn))); for (unsigned argno = 1; ; ++argno) { code = (enum tree_code) va_arg (ap, int); - bool nonnull = false; switch (code) { @@ -1072,15 +1072,21 @@ validate_arglist (const_tree callexpr, ...) /* The actual argument must be nonnull when either the whole called function has been declared nonnull, or when the formal argument corresponding to the actual argument has been. */ - if (argmap) - nonnull = bitmap_empty_p (argmap) || bitmap_bit_p (argmap, argno); + if (argmap + && (bitmap_empty_p (argmap) || bitmap_bit_p (argmap, argno))) + { + arg = next_const_call_expr_arg (&iter); + if (!validate_arg (arg, code) || integer_zerop (arg)) + goto end; + break; + } /* FALLTHRU */ default: /* If no parameters remain or the parameter's code does not match the specified code, return false. Otherwise continue checking any remaining arguments. */ arg = next_const_call_expr_arg (&iter); - if (!validate_arg (arg, code, nonnull)) + if (!validate_arg (arg, code)) goto end; break; } @@ -9134,17 +9140,15 @@ rewrite_call_expr (location_t loc, tree exp, int skip, tree fndecl, int n, ...) } /* Validate a single argument ARG against a tree code CODE representing - a type. When NONNULL is true consider a pointer argument valid only - if it's non-null. Return true when argument is valid. */ + a type. Return true when argument is valid. */ static bool -validate_arg (const_tree arg, enum tree_code code, bool nonnull /*= false*/) +validate_arg (const_tree arg, enum tree_code code) { if (!arg) return false; else if (code == POINTER_TYPE) - return POINTER_TYPE_P (TREE_TYPE (arg)) - && (!nonnull || !integer_zerop (arg)); + return POINTER_TYPE_P (TREE_TYPE (arg)); else if (code == INTEGER_TYPE) return INTEGRAL_TYPE_P (TREE_TYPE (arg)); return code == TREE_CODE (TREE_TYPE (arg)); |