Bug 21911 - named parameter mistakenly identified as sentinel
Summary: named parameter mistakenly identified as sentinel
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Kaveh Ghazi
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-06-04 12:46 UTC by Kaveh Ghazi
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaveh Ghazi 2005-06-04 12:46:22 UTC
GCC mistakenly identifies a named parameter as a sentinel.  Given the following 
program, compiling with -Wformat GCC should warn about a missing sentinel on 
the line indicated:

#include <stddef.h>

extern void foo (const char *, ...) __attribute__ ((__sentinel__));

void bar (void)
{
  foo (NULL); /* missing warning!! */
  foo ("hello", NULL); /* clean */
}

When looking for the sentinel, GCC should skip over the named arguments first 
before attempting to locate the NULL pointer.
Comment 1 Kaveh Ghazi 2005-06-06 18:41:39 UTC
Patch here:
http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00507.html
Comment 2 CVS Commits 2005-06-26 21:54:39 UTC
Subject: Bug 21911

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ghazi@gcc.gnu.org	2005-06-26 21:54:25

Modified files:
	gcc            : ChangeLog c-common.c c-common.h c-typeck.c 
	gcc/cp         : ChangeLog call.c typeck.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg/format: sentinel-1.c 

Log message:
	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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9237&r2=2.9238
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&r1=1.638&r2=1.639
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&r1=1.296&r2=1.297
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.459&r2=1.460
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4800&r2=1.4801
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&r1=1.541&r2=1.542
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&r1=1.639&r2=1.640
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5689&r2=1.5690
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/format/sentinel-1.c.diff?cvsroot=gcc&r1=1.2&r2=1.3

Comment 3 Andrew Pinski 2005-06-26 22:14:51 UTC
Fixed.
Comment 4 CVS Commits 2005-07-08 14:01:00 UTC
Subject: Bug 21911

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	ghazi@gcc.gnu.org	2005-07-08 13:59:35

Modified files:
	gcc            : ChangeLog c-common.c c-common.h c-typeck.c 
	gcc/cp         : ChangeLog call.c typeck.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg/format: sentinel-1.c 

Log message:
	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.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.299&r2=2.7592.2.300
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.606.2.4&r2=1.606.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-common.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.277.2.2&r2=1.277.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.419.2.8&r2=1.419.2.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.60&r2=1.4648.2.61
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/call.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.531.2.3&r2=1.531.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.616.2.9&r2=1.616.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.251&r2=1.5084.2.252
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/format/sentinel-1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.2&r2=1.2.48.1