aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2005-06-26 21:54:24 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2005-06-26 21:54:24 +0000
commit10a22b110764c1c665fa2ff5f29607bdeb8f79ba (patch)
tree41908d1e14fb3ba4c882eacbba3fca4d4f164007 /gcc/c-common.c
parent82e5a12a581ea11e83cbd94d368e3297abda8fe2 (diff)
downloadgcc-10a22b110764c1c665fa2ff5f29607bdeb8f79ba.zip
gcc-10a22b110764c1c665fa2ff5f29607bdeb8f79ba.tar.gz
gcc-10a22b110764c1c665fa2ff5f29607bdeb8f79ba.tar.bz2
re PR c/21911 (named parameter mistakenly identified as sentinel)
PR c/21911 * c-common.c (check_function_sentinel): Pass in named argument list, skip over named arguments before looking for a sentinel. (check_function_arguments): Pass in named argument list. * c-common.h (check_function_arguments): Likewise. * c-typeck.c (build_function_call): Likewise. cp: * call.c (build_over_call): Pass in named argument list to `check_function_arguments'. * typeck.c (build_function_call): Likewise. testsuite: PR c/21911 * gcc.dg/format/sentinel-1.c: Update. Fix execl* calls. From-SVN: r101341
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 6b753dc..24280ae 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5143,14 +5143,21 @@ check_function_nonnull (tree attrs, tree params)
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;
@@ -5172,7 +5179,7 @@ check_function_sentinel (tree attrs, tree params)
}
if (pos > 0)
{
- warning (0, "not enough arguments to fit a sentinel");
+ warning (0, "not enough variable arguments to fit a sentinel");
return;
}
@@ -5386,7 +5393,7 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
/* 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. */
@@ -5399,7 +5406,7 @@ check_function_arguments (tree attrs, tree params)
if (warn_format)
{
check_function_format (attrs, params);
- check_function_sentinel (attrs, params);
+ check_function_sentinel (attrs, params, typelist);
}
}