from the end) is a (pointer)0. */
static void
-check_function_sentinel (tree attrs, tree params)
+check_function_sentinel (tree attrs, tree params, tree typelist)
{
tree attr = lookup_attribute ("sentinel", attrs);
if (attr)
{
- if (!params)
- warning (0, "missing sentinel in function call");
+ /* Skip over the named arguments. */
+ while (typelist && params)
+ {
+ typelist = TREE_CHAIN (typelist);
+ params = TREE_CHAIN (params);
+ }
+
+ if (typelist || !params)
+ warning (0, "not enough variable arguments to fit a sentinel");
else
{
tree sentinel, end;
}
if (pos > 0)
{
- warning (0, "not enough arguments to fit a sentinel");
+ warning (0, "not enough variable arguments to fit a sentinel");
return;
}
\f
/* Check for valid arguments being passed to a function. */
void
-check_function_arguments (tree attrs, tree params)
+check_function_arguments (tree attrs, tree params, tree typelist)
{
/* Check for null being passed in a pointer argument that must be
non-null. We also need to do this if format checking is enabled. */
if (warn_format)
{
check_function_format (attrs, params);
- check_function_sentinel (attrs, params);
+ check_function_sentinel (attrs, params, typelist);
}
}
extern void bar(void)
{
- foo1 (); /* { dg-error "missing sentinel|too few arguments" "sentinel" } */
- foo1 ("a"); /* { dg-warning "missing sentinel" "sentinel" } */
+ foo1 (); /* { dg-error "not enough|too few arguments" "sentinel" } */
+ foo1 (NULL); /* { dg-warning "not enough" "sentinel" } */
+ foo1 ("a"); /* { dg-warning "not enough" "sentinel" } */
foo1 ("a", 1); /* { dg-warning "missing sentinel" "sentinel" } */
foo1 ("a", 0); /* { dg-warning "missing sentinel" "sentinel" } */
foo1 ("a", (void*)1); /* { dg-warning "missing sentinel" "sentinel" } */
foo1 ("a", NULL, 1); /* { dg-warning "missing sentinel" "sentinel" } */
foo1 ("a", NULL);
+ foo5 (NULL); /* { dg-warning "not enough" "sentinel" } */
+ foo5 (NULL, 1); /* { dg-warning "not enough" "sentinel" } */
+ foo5 ("a", NULL); /* { dg-warning "not enough" "sentinel" } */
+ foo5 ("a", NULL, 1);
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", 1, NULL); /* { dg-warning "not enough" "sentinel" } */
+ foo6 ("a", 1, NULL, 2); /* { dg-warning "not enough" "sentinel" } */
+ foo6 ("a", 1, NULL, 2, 3); /* { dg-warning "not enough" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3); /* { dg-warning "not enough" "sentinel" } */
+ foo6 ("a", NULL, 1, 2, 3, 4); /* { dg-warning "not enough" "sentinel" } */
+ foo6 (NULL, 1, 2, 3, 4, 5); /* { dg-warning "not enough" "sentinel" } */
foo6 ("a", NULL, 1, 2, 3, 4, 5);
+ foo6 ("a", 0, 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);
+ execl ("/bin/ls", "/bin/ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
+ execl ("/bin/ls", "/bin/ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
+ execl ("/bin/ls", "/bin/ls", "-aFC", NULL);
- execlp ("ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
- execlp ("ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
- execlp ("ls", "-aFC", NULL);
+ execlp ("ls", "ls", "-aFC"); /* { dg-warning "missing sentinel" "sentinel" } */
+ execlp ("ls", "ls", "-aFC", 0); /* { dg-warning "missing sentinel" "sentinel" } */
+ execlp ("ls", "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);
+ execle ("ls", "ls", "-aFC", ".", envp); /* { dg-warning "missing sentinel" "sentinel" } */
+ execle ("ls", "ls", "-aFC", ".", 0, envp); /* { dg-warning "missing sentinel" "sentinel" } */
+ execle ("ls", "ls", "-aFC", ".", NULL, envp);
}