mips.h (ISA_HAS_DSP, [...]): New macros.
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-alloc_size.c
blob47d7c0050853fd377d588be96db232a5a2ecfc36
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wall" } */
4 extern void abort (void);
6 #include "../gcc.c-torture/execute/builtins/chk.h"
8 extern char *mallocminus1(int size) __attribute__((alloc_size(-1))); /* { dg-warning "parameter outside range" } */
9 extern char *malloc0(int size) __attribute__((alloc_size(0))); /* { dg-warning "parameter outside range" } */
10 extern char *malloc1(int size) __attribute__((alloc_size(1)));
11 extern char *malloc2(int empty, int size) __attribute__((alloc_size(2)));
12 extern char *calloc1(int size, int elements) __attribute__((alloc_size(1,2)));
13 extern char *calloc2(int size, int empty, int elements) __attribute__((alloc_size(1,3)));
14 extern char *balloc1(void *size) __attribute__((alloc_size(1)));
16 void
17 test (void)
19 char *p;
21 p = malloc0 (6);
22 strcpy (p, "Hello");
23 p = malloc1 (6);
24 strcpy (p, "Hello");
25 strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
26 p = malloc2 (__INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 6);
27 strcpy (p, "World");
28 strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
29 p = calloc1 (2, 5);
30 strcpy (p, "World");
31 strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */
32 p = calloc2 (2, __INT_MAX__ >= 1700000 ? 424242 : __INT_MAX__ / 4, 5);
33 strcpy (p, "World");
34 strcpy (p, "Hello World"); /* { dg-warning "will always overflow" "strcpy" } */