aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format/sentinel-1.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2004-09-05 02:55:28 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2004-09-05 02:55:28 +0000
commit254986c7ff3175c29307b999f161cfcc7961baf4 (patch)
tree35944d27904d831ba5d78370c59d633d19c4fe13 /gcc/testsuite/gcc.dg/format/sentinel-1.c
parent44269c4093f881d5321ee09d40490e1989345bae (diff)
downloadgcc-254986c7ff3175c29307b999f161cfcc7961baf4.zip
gcc-254986c7ff3175c29307b999f161cfcc7961baf4.tar.gz
gcc-254986c7ff3175c29307b999f161cfcc7961baf4.tar.bz2
builtin-attrs.def (ATTR_NOTHROW_SENTINEL_1): New.
* builtin-attrs.def (ATTR_NOTHROW_SENTINEL_1): New. * builtins.def (BUILT_IN_EXECLE): Set ATTR_NOTHROW_SENTINEL_1. * c-common.c (c_common_attribute_table): Accept parameters to sentinel attribute. (check_function_sentinel, handle_sentinel_attribute): Likewise. * doc/extend.texi: Update accordingly. testsuite: * gcc.dg/format/sentinel-1.c: Update for parameter option. From-SVN: r87098
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/sentinel-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/format/sentinel-1.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/sentinel-1.c b/gcc/testsuite/gcc.dg/format/sentinel-1.c
index e1e127dc..12915b7 100644
--- a/gcc/testsuite/gcc.dg/format/sentinel-1.c
+++ b/gcc/testsuite/gcc.dg/format/sentinel-1.c
@@ -7,6 +7,8 @@
extern int execl (const char *, const char *, ...);
extern int execlp (const char *, const char *, ...);
+extern int execle (const char *, const char *, ...);
+extern char *envp[];
#define ATTR __attribute__ ((__sentinel__))
@@ -16,6 +18,12 @@ extern void foo1 (const char *, ...) ATTR;
extern void foo2 (...) ATTR; /* { dg-error "ISO C requires|named arguments" "sentinel" } */
extern void foo3 () ATTR; /* { dg-warning "named arguments" "sentinel" } */
extern void foo4 (const char *, int) ATTR; /* { dg-warning "variadic functions" "sentinel" } */
+extern void foo5 (const char *, ...) __attribute__ ((__sentinel__(1)));
+extern void foo6 (const char *, ...) __attribute__ ((__sentinel__(5)));
+extern void foo7 (const char *, ...) __attribute__ ((__sentinel__(0)));
+extern void foo8 (const char *, ...) __attribute__ ((__sentinel__("a"))); /* { dg-warning "not an integer constant" "sentinel" } */
+extern void foo9 (const char *, ...) __attribute__ ((__sentinel__(-1))); /* { dg-warning "less than zero" "sentinel" } */
+extern void foo10 (const char *, ...) __attribute__ ((__sentinel__(1,3))); /* { dg-error "wrong number of arguments" "sentinel" } */
extern void bar(void)
{
@@ -27,6 +35,23 @@ extern void bar(void)
foo1 ("a", NULL, 1); /* { dg-warning "missing sentinel" "sentinel" } */
foo1 ("a", NULL);
+ foo5 ("a", 1, 2, 3, NULL); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo5 ("a", 1, 2, NULL, 3);
+ foo5 ("a", 1, NULL, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo5 ("a", NULL, 1, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo5 ("a", 0, 1, 2, 3); /* { dg-warning "missing sentinel" "sentinel" } */
+
+ foo6 ("a", 1, NULL); /* { dg-warning "not enough arguments" "sentinel" } */
+ foo6 ("a", 1, NULL, 2); /* { dg-warning "not enough arguments" "sentinel" } */
+ foo6 ("a", 1, NULL, 2, 3); /* { dg-warning "not enough arguments" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3); /* { dg-warning "not enough arguments" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3, 4); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3, 4, 5);
+ foo6 ("a", 0, 1, 2, 3, 4, 5); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3, 4, 5, 6); /* { dg-warning "missing sentinel" "sentinel" } */
+
+ foo7 ("a", 1, 2, 3, NULL);
+
execl ("/bin/ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
execl ("/bin/ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
execl ("/bin/ls", "-aFC", NULL);
@@ -34,4 +59,8 @@ extern void bar(void)
execlp ("ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
execlp ("ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
execlp ("ls", "-aFC", NULL);
+
+ execle ("ls", "-aFC", ".", envp); /* { dg-warning "missing sentinel" "sentinel" } */
+ execle ("ls", "-aFC", ".", 0, envp); /* { dg-warning "missing sentinel" "sentinel" } */
+ execle ("ls", "-aFC", ".", NULL, envp);
}