aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-07-20 11:37:25 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2012-07-20 11:37:25 +0200
commit332f1d2404d4e69a8fb88a3d2b6fc302901caec4 (patch)
tree25252a03826e4bf84e9d1273eae3b049d63f7537 /gcc/tree-vrp.c
parent3c82efd91f3f8f1f957907fd7d902e26279239e9 (diff)
downloadgcc-332f1d2404d4e69a8fb88a3d2b6fc302901caec4.zip
gcc-332f1d2404d4e69a8fb88a3d2b6fc302901caec4.tar.gz
gcc-332f1d2404d4e69a8fb88a3d2b6fc302901caec4.tar.bz2
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
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c45
1 files changed, 24 insertions, 21 deletions
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;