Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / format / sentinel-1.c
blob1dc090870e42eaa5a0b31614a042020ce80b0bfb
1 /* Test for attribute sentinel. */
2 /* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> */
3 /* { dg-do compile } */
4 /* { dg-options "-Wformat" } */
6 #include <stddef.h> /* For NULL, which must be (ptr)0. */
8 extern int execl (const char *, const char *, ...);
9 extern int execlp (const char *, const char *, ...);
10 extern int execle (const char *, const char *, ...);
11 extern char *envp[];
13 #define ATTR __attribute__ ((__sentinel__))
15 extern int a ATTR; /* { dg-warning "applies to function types" "sentinel" } */
17 extern void foo1 (const char *, ...) ATTR;
18 extern void foo2 (...) ATTR; /* { dg-error "ISO C requires|named arguments" "sentinel" } */
19 extern void foo3 () ATTR; /* { dg-warning "named arguments" "sentinel" } */
20 extern void foo4 (const char *, int) ATTR; /* { dg-warning "variadic functions" "sentinel" } */
21 extern void foo5 (const char *, ...) __attribute__ ((__sentinel__(1)));
22 extern void foo6 (const char *, ...) __attribute__ ((__sentinel__(5)));
23 extern void foo7 (const char *, ...) __attribute__ ((__sentinel__(0)));
24 extern void foo8 (const char *, ...) __attribute__ ((__sentinel__("a"))); /* { dg-warning "not an integer constant" "sentinel" } */
25 extern void foo9 (const char *, ...) __attribute__ ((__sentinel__(-1))); /* { dg-warning "less than zero" "sentinel" } */
26 extern void foo10 (const char *, ...) __attribute__ ((__sentinel__(1,3))); /* { dg-error "wrong number of arguments" "sentinel" } */
28 extern void bar(void)
30 foo1 (); /* { dg-error "not enough|too few arguments" "sentinel" } */
31 foo1 (NULL); /* { dg-warning "not enough" "sentinel" } */
32 foo1 ("a"); /* { dg-warning "not enough" "sentinel" } */
33 foo1 ("a", 1); /* { dg-warning "missing sentinel" "sentinel" } */
34 foo1 ("a", 0); /* { dg-warning "missing sentinel" "sentinel" } */
35 foo1 ("a", (void*)1); /* { dg-warning "missing sentinel" "sentinel" } */
36 foo1 ("a", NULL, 1); /* { dg-warning "missing sentinel" "sentinel" } */
37 foo1 ("a", NULL);
39 foo5 (NULL); /* { dg-warning "not enough" "sentinel" } */
40 foo5 (NULL, 1); /* { dg-warning "not enough" "sentinel" } */
41 foo5 ("a", NULL); /* { dg-warning "not enough" "sentinel" } */
42 foo5 ("a", NULL, 1);
43 foo5 ("a", 1, 2, 3, NULL); /* { dg-warning "missing sentinel" "sentinel" } */
44 foo5 ("a", 1, 2, NULL, 3);
45 foo5 ("a", 1, NULL, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
46 foo5 ("a", NULL, 1, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
47 foo5 ("a", 0, 1, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
49 foo6 ("a", 1, NULL); /* { dg-warning "not enough" "sentinel" } */
50 foo6 ("a", 1, NULL, 2); /* { dg-warning "not enough" "sentinel" } */
51 foo6 ("a", 1, NULL, 2, 3); /* { dg-warning "not enough" "sentinel" } */
52 foo6 ("a", NULL, 1, 2, 3); /* { dg-warning "not enough" "sentinel" } */
53 foo6 ("a", NULL, 1, 2, 3, 4); /* { dg-warning "not enough" "sentinel" } */
54 foo6 (NULL, 1, 2, 3, 4, 5); /* { dg-warning "not enough" "sentinel" } */
55 foo6 ("a", NULL, 1, 2, 3, 4, 5);
56 foo6 ("a", 0, NULL, 1, 2, 3, 4, 5);
57 foo6 ("a", 0, 1, 2, 3, 4, 5); /* { dg-warning "missing sentinel" "sentinel" } */
58 foo6 ("a", NULL, 1, 2, 3, 4, 5, 6); /* { dg-warning "missing sentinel" "sentinel" } */
60 foo7 ("a", 1, 2, 3, NULL);
62 execl ("/bin/ls", "/bin/ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
63 execl ("/bin/ls", "/bin/ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
64 execl ("/bin/ls", "/bin/ls", "-aFC", NULL);
66 execlp ("ls", "ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
67 execlp ("ls", "ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
68 execlp ("ls", "ls", "-aFC", NULL);
70 execle ("ls", "ls", "-aFC", ".", envp); /* { dg-warning "missing sentinel" "sentinel" } */
71 execle ("ls", "ls", "-aFC", ".", 0, envp); /* { dg-warning "missing sentinel" "sentinel" } */
72 execle ("ls", "ls", "-aFC", ".", NULL, envp);