aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-12-21 23:15:59 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-12-21 23:15:59 +0100
commit0dba79602a7e3fb62bebee58b2cd7c24115b4faf (patch)
tree5cf6b631ea6cd0b3f5aca6c10361d66c4b8c572b /gcc/c-family
parentbc2a38dff859fcd1ec0aedd8c7d0fb748f2dbede (diff)
downloadgcc-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/c-family')
-rw-r--r--gcc/c-family/ChangeLog11
-rw-r--r--gcc/c-family/c-common.c43
-rw-r--r--gcc/c-family/c-common.h2
3 files changed, 43 insertions, 13 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 13ba2f3..acdedc8 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,14 @@
+2016-12-21 Jakub Jelinek <jakub@redhat.com>
+
+ PR bootstrap/78817
+ * 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.
+
2016-12-21 Jason Merrill <jason@redhat.com>
* c.opt (-fnew-ttp-matching): New flag.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index b690afb..81dc888 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5250,11 +5250,21 @@ c_determine_visibility (tree decl)
return false;
}
+/* Data to communicate through check_function_arguments_recurse between
+ check_function_nonnull and check_nonnull_arg. */
+
+struct nonnull_arg_ctx
+{
+ location_t loc;
+ bool warned_p;
+};
+
/* Check the argument list of a function call for null in argument slots
that are marked as requiring a non-null pointer argument. The NARGS
- arguments are passed in the array ARGARRAY. */
+ arguments are passed in the array ARGARRAY. Return true if we have
+ warned. */
-static void
+static bool
check_function_nonnull (location_t loc, tree attrs, int nargs, tree *argarray)
{
tree a;
@@ -5262,7 +5272,7 @@ check_function_nonnull (location_t loc, tree attrs, int nargs, tree *argarray)
attrs = lookup_attribute ("nonnull", attrs);
if (attrs == NULL_TREE)
- return;
+ return false;
a = attrs;
/* See if any of the nonnull attributes has no arguments. If so,
@@ -5273,9 +5283,10 @@ check_function_nonnull (location_t loc, tree attrs, int nargs, tree *argarray)
a = lookup_attribute ("nonnull", TREE_CHAIN (a));
while (a != NULL_TREE && TREE_VALUE (a) != NULL_TREE);
+ struct nonnull_arg_ctx ctx = { loc, false };
if (a != NULL_TREE)
for (i = 0; i < nargs; i++)
- check_function_arguments_recurse (check_nonnull_arg, &loc, argarray[i],
+ check_function_arguments_recurse (check_nonnull_arg, &ctx, argarray[i],
i + 1);
else
{
@@ -5291,10 +5302,11 @@ check_function_nonnull (location_t loc, tree attrs, int nargs, tree *argarray)
}
if (a != NULL_TREE)
- check_function_arguments_recurse (check_nonnull_arg, &loc,
+ check_function_arguments_recurse (check_nonnull_arg, &ctx,
argarray[i], i + 1);
}
}
+ return ctx.warned_p;
}
/* Check that the Nth argument of a function call (counting backwards
@@ -5379,7 +5391,7 @@ nonnull_check_p (tree args, unsigned HOST_WIDE_INT param_num)
static void
check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num)
{
- location_t *ploc = (location_t *) ctx;
+ struct nonnull_arg_ctx *pctx = (struct nonnull_arg_ctx *) ctx;
/* Just skip checking the argument if it's not a pointer. This can
happen if the "nonnull" attribute was given without an operand
@@ -5391,9 +5403,12 @@ check_nonnull_arg (void *ctx, tree param, unsigned HOST_WIDE_INT param_num)
/* When not optimizing diagnose the simple cases of null arguments.
When optimization is enabled defer the checking until expansion
when more cases can be detected. */
- if (!optimize && integer_zerop (param))
- warning_at (*ploc, OPT_Wnonnull, "null argument where non-null required "
- "(argument %lu)", (unsigned long) param_num);
+ if (integer_zerop (param))
+ {
+ warning_at (pctx->loc, OPT_Wnonnull, "null argument where non-null "
+ "required (argument %lu)", (unsigned long) param_num);
+ pctx->warned_p = true;
+ }
}
/* Helper for nonnull attribute handling; fetch the operand number
@@ -5587,16 +5602,19 @@ attribute_fallthrough_p (tree attr)
/* Check for valid arguments being passed to a function with FNTYPE.
There are NARGS arguments in the array ARGARRAY. LOC should be used for
- diagnostics. */
-void
+ diagnostics. Return true if -Wnonnull warning has been diagnosed. */
+bool
check_function_arguments (location_t loc, const_tree fntype, int nargs,
tree *argarray)
{
+ bool warned_p = false;
+
/* Check for null being passed in a pointer argument that must be
non-null. We also need to do this if format checking is enabled. */
if (warn_nonnull)
- check_function_nonnull (loc, TYPE_ATTRIBUTES (fntype), nargs, argarray);
+ warned_p = check_function_nonnull (loc, TYPE_ATTRIBUTES (fntype),
+ nargs, argarray);
/* Check for errors in format strings. */
@@ -5605,6 +5623,7 @@ check_function_arguments (location_t loc, const_tree fntype, int nargs,
if (warn_format)
check_function_sentinel (fntype, nargs, argarray);
+ return warned_p;
}
/* Generic argument checking recursion routine. PARAM is the argument to
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index a23193e..b9131e3 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -804,7 +804,7 @@ extern const char *fname_as_string (int);
extern tree fname_decl (location_t, unsigned, tree);
extern int check_user_alignment (const_tree, bool);
-extern void check_function_arguments (location_t loc, const_tree, int, tree *);
+extern bool check_function_arguments (location_t loc, const_tree, int, tree *);
extern void check_function_arguments_recurse (void (*)
(void *, tree,
unsigned HOST_WIDE_INT),