1 /* { dg-do compile } */
2 /* { dg-options "-Wcalloc-transposed-args" } */
4 typedef __SIZE_TYPE__
size_t;
6 void *calloc (size_t, size_t);
7 void *myfree (void *, int, int);
8 void *mycalloc (int, int, size_t, size_t) __attribute__((malloc
, malloc (myfree
), alloc_size (3, 4)));
14 p
= __builtin_calloc (1, sizeof (int));
16 p
= __builtin_calloc (n
, sizeof (int));
18 p
= __builtin_calloc (sizeof (int), 1); /* { dg-warning "'__builtin_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
19 __builtin_free (p
); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
20 p
= __builtin_calloc (sizeof (int), n
); /* { dg-warning "'__builtin_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
21 __builtin_free (p
); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
22 p
= __builtin_calloc ((sizeof (int)), 1); /* { dg-warning "'__builtin_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
23 __builtin_free (p
); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
24 p
= __builtin_calloc (sizeof (int) + 0, 1);
26 p
= __builtin_calloc (sizeof (int), sizeof (char));
28 p
= __builtin_calloc (1 * sizeof (int), 1);
30 p
= calloc (1, sizeof (int));
32 p
= calloc (n
, sizeof (int));
34 p
= calloc (sizeof (int), 1); /* { dg-warning "'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
35 free (p
); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
36 p
= calloc (sizeof (int), n
); /* { dg-warning "'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
37 free (p
); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
38 p
= calloc (sizeof (int), sizeof (char));
40 p
= calloc (1 * sizeof (int), 1);
42 p
= mycalloc (42, 42, 1, sizeof (int));
44 p
= mycalloc (42, 42, n
, sizeof (int));
46 p
= mycalloc (42, 42, sizeof (int), 1); /* { dg-warning "'mycalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
47 myfree (p
, 42, 42); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
48 p
= mycalloc (42, 42, sizeof (int), n
); /* { dg-warning "'mycalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument" } */
49 myfree (p
, 42, 42); /* { dg-message "earlier argument should specify number of elements, later size of each element" "" { target *-*-* } .-1 } */
50 p
= mycalloc (42, 42, sizeof (int), sizeof (char));
52 p
= mycalloc (42, 42, 1 * sizeof (int), 1);