OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [format/] [sentinel-1.c] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Test for attribute sentinel.  */
2
/* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> */
3
/* { dg-do compile } */
4
/* { dg-options "-Wformat" } */
5
 
6
#include <stddef.h> /* For NULL, which must be (ptr)0.  */
7
 
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[];
12
 
13
#define ATTR __attribute__ ((__sentinel__))
14
 
15
extern int a ATTR; /* { dg-warning "applies to function types" "sentinel" } */
16
 
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" } */
27
 
28
extern void bar(void)
29
{
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);
38
 
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" } */
48
 
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" } */
59
 
60
  foo7 ("a", 1, 2, 3, NULL);
61
 
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);
65
 
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);
69
 
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);
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.