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/tree-ssa-ccp.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/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index fb90d02..24a9fc1 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -144,6 +144,7 @@ along with GCC; see the file COPYING3. If not see #include "optabs-query.h" #include "tree-ssa-ccp.h" #include "tree-dfa.h" +#include "diagnostic-core.h" /* Possible lattice values. */ typedef enum @@ -3316,3 +3317,97 @@ make_pass_fold_builtins (gcc::context *ctxt) { return new pass_fold_builtins (ctxt); } + +/* A simple pass that emits some warnings post IPA. */ + +namespace { + +const pass_data pass_data_post_ipa_warn = +{ + GIMPLE_PASS, /* type */ + "post_ipa_warn", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_NONE, /* tv_id */ + ( PROP_cfg | PROP_ssa ), /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_post_ipa_warn : public gimple_opt_pass +{ +public: + pass_post_ipa_warn (gcc::context *ctxt) + : gimple_opt_pass (pass_data_post_ipa_warn, ctxt) + {} + + /* opt_pass methods: */ + opt_pass * clone () { return new pass_post_ipa_warn (m_ctxt); } + virtual bool gate (function *) { return warn_nonnull != 0; } + virtual unsigned int execute (function *); + +}; // class pass_fold_builtins + +unsigned int +pass_post_ipa_warn::execute (function *fun) +{ + basic_block bb; + + FOR_EACH_BB_FN (bb, fun) + { + gimple_stmt_iterator gsi; + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + if (!is_gimple_call (stmt) || gimple_no_warning_p (stmt)) + continue; + + if (warn_nonnull) + { + bitmap nonnullargs + = get_nonnull_args (gimple_call_fntype (stmt)); + if (nonnullargs) + { + for (unsigned i = 0; i < gimple_call_num_args (stmt); i++) + { + tree arg = gimple_call_arg (stmt, i); + if (TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE) + continue; + if (!integer_zerop (arg)) + continue; + if (!bitmap_empty_p (nonnullargs) + && !bitmap_bit_p (nonnullargs, i)) + continue; + + location_t loc = gimple_location (stmt); + if (warning_at (loc, OPT_Wnonnull, + "argument %u null where non-null " + "expected", i + 1)) + { + tree fndecl = gimple_call_fndecl (stmt); + if (fndecl && DECL_IS_BUILTIN (fndecl)) + inform (loc, "in a call to built-in function %qD", + fndecl); + else if (fndecl) + inform (DECL_SOURCE_LOCATION (fndecl), + "in a call to function %qD declared here", + fndecl); + + } + } + BITMAP_FREE (nonnullargs); + } + } + } + } + return 0; +} + +} // anon namespace + +gimple_opt_pass * +make_pass_post_ipa_warn (gcc::context *ctxt) +{ + return new pass_post_ipa_warn (ctxt); +} |