OSDN Git Service

2008-04-23 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Apr 2008 13:47:38 +0000 (13:47 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Apr 2008 13:47:38 +0000 (13:47 +0000)
PR middle-end/36021
* c-common.c (handle_alloc_size_attribute): Use type_num_arguments.

* gcc.dg/attr-alloc_size-2.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134595 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-alloc_size-2.c [new file with mode: 0644]

index 50b7fc2..f0fb840 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-23  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36021
+       * c-common.c (handle_alloc_size_attribute): Use type_num_arguments.
+
 2008-04-22  Tomas Bily  <tbily@suse.cz>
 
         * tree-cfg.c (verify_expr): Check for NON_LVALUE_EXPR as unreachable
index 351c628..a18752e 100644 (file)
@@ -5941,12 +5941,7 @@ static tree
 handle_alloc_size_attribute (tree *node, tree ARG_UNUSED (name), tree args,
                             int ARG_UNUSED (flags), bool *no_add_attrs)
 {
-  tree params = TYPE_ARG_TYPES (*node);
-  unsigned arg_count = 0;
-
-  for (; TREE_CHAIN (params); params = TREE_CHAIN (params))
-    arg_count ++;
-
+  unsigned arg_count = type_num_arguments (*node);
   for (; args; args = TREE_CHAIN (args))
     {
       tree position = TREE_VALUE (args);
index 9493fef..d5828e8 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-23  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/36021
+       * gcc.dg/attr-alloc_size-2.c: New testcase.
+
 2008-04-23  Kai Tietz  <kai.tietz@onevision.com>
 
        * gcc.dg/20020919-1.c (loc_size_t): New type.
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-2.c b/gcc/testsuite/gcc.dg/attr-alloc_size-2.c
new file mode 100644 (file)
index 0000000..3cac807
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+
+char *foo() __attribute__((alloc_size(1))); /* { dg-warning "outside range" } */
+