From 332f1d2404d4e69a8fb88a3d2b6fc302901caec4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 20 Jul 2012 11:37:25 +0200 Subject: re PR c++/28656 (duplicated null argument warning on memcpy()) PR c++/28656 * tree-vrp.c (nonnull_arg_p): Handle all nonnull attributes instead of just the first one. * c-common.c (check_function_nonnull): Handle multiple nonnull attributes properly. * c-c++-common/pr28656.c: New test. From-SVN: r189707 --- gcc/tree-vrp.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'gcc/tree-vrp.c') diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 66cc406..68c449e 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -353,32 +353,35 @@ nonnull_arg_p (const_tree arg) return true; fntype = TREE_TYPE (current_function_decl); - attrs = lookup_attribute ("nonnull", TYPE_ATTRIBUTES (fntype)); + for (attrs = TYPE_ATTRIBUTES (fntype); attrs; attrs = TREE_CHAIN (attrs)) + { + attrs = lookup_attribute ("nonnull", attrs); - /* If "nonnull" wasn't specified, we know nothing about the argument. */ - if (attrs == NULL_TREE) - return false; + /* If "nonnull" wasn't specified, we know nothing about the argument. */ + if (attrs == NULL_TREE) + return false; - /* If "nonnull" applies to all the arguments, then ARG is non-null. */ - if (TREE_VALUE (attrs) == NULL_TREE) - return true; + /* If "nonnull" applies to all the arguments, then ARG is non-null. */ + if (TREE_VALUE (attrs) == NULL_TREE) + return true; - /* Get the position number for ARG in the function signature. */ - for (arg_num = 1, t = DECL_ARGUMENTS (current_function_decl); - t; - t = DECL_CHAIN (t), arg_num++) - { - if (t == arg) - break; - } + /* Get the position number for ARG in the function signature. */ + for (arg_num = 1, t = DECL_ARGUMENTS (current_function_decl); + t; + t = DECL_CHAIN (t), arg_num++) + { + if (t == arg) + break; + } - gcc_assert (t == arg); + gcc_assert (t == arg); - /* Now see if ARG_NUM is mentioned in the nonnull list. */ - for (t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t)) - { - if (compare_tree_int (TREE_VALUE (t), arg_num) == 0) - return true; + /* Now see if ARG_NUM is mentioned in the nonnull list. */ + for (t = TREE_VALUE (attrs); t; t = TREE_CHAIN (t)) + { + if (compare_tree_int (TREE_VALUE (t), arg_num) == 0) + return true; + } } return false; -- cgit v1.1