Date: Sat, 25 May 2002 20:02:04 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Peter Wemm <peter@wemm.org> Cc: "David E. O'Brien" <obrien@FreeBSD.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org> Subject: Re: cvs commit: src/contrib/gcc c-format.c Message-ID: <20020525195005.I6995-100000@gamplex.bde.org> In-Reply-To: <20020524192714.DC2033807@overcee.wemm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 24 May 2002, Peter Wemm wrote: > "David E. O'Brien" wrote: > > obrien 2002/05/22 09:37:09 PDT > > > > Modified files: > > contrib/gcc c-format.c > > Log: > > 1/2assed reimplementation of c-common.c revs 1.2 (-fformat-extensions) > > and 1.3 (printf0) for GCC 3.1. > > This is not quite right: > ... > ie: it doesn't seem to like the size argument, which is clearly documented > in the comments and well used in the kernel. eg: > > ../../../dev/an/if_an.c: In function `an_attach': > ../../../dev/an/if_an.c:444: warning: too many arguments for format > > Also: > ../../../kern/tty_pty.c: In function `ptyinit': > ../../../kern/tty_pty.c:158: warning: use of `' length modifier with `r' type character > ../../../kern/tty_pty.c: In function `pty_clone': > ../../../kern/tty_pty.c:860: warning: use of `' length modifier with `r' type character > > I think this is the opposite problem to above. %r appears to require a size > argument in the checking while %D appears to prohibit one. This is mostly because the special checks for %b and %D are done before skipping over any characters between the % and the [bD], so only plain %b and %B worked. The following fix sees to work. It just moves the special checks much later and fixes some minor style bugs. I think the checks should be even later in another function?). gcc now has more intelligence built into the tables so it isn't so obvious where to put the special checks. %%% Index: c-format.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-format.c,v retrieving revision 1.3 diff -u -2 -r1.3 c-format.c --- c-format.c 22 May 2002 16:37:09 -0000 1.3 +++ c-format.c 25 May 2002 09:44:19 -0000 @@ -798,7 +798,7 @@ ("%*D", len, ptr, " ") -> XX XX XX XX ... */ - { "D", 1, STD_EXT, { T89_C, T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR" }, - { "b", 1, STD_EXT, { T89_C, T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "" }, - { "rz", 0, STD_EXT, { BADLEN, T89_I, T89_I, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "i" }, + { "D", 1, STD_EXT, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "cR" }, + { "b", 1, STD_EXT, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp", "" }, + { "rz", 0, STD_EXT, { T89_I, BADLEN, BADLEN, T89_L, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "-wp0 +#", "i" }, { NULL, 0, 0, NOLENGTHS, NULL, NULL } }; @@ -1741,52 +1741,4 @@ } } - if (*format_chars == 'b') - { - /* There should be an int arg to control the string arg. */ - if (params == 0) - { - status_warning (status, "too few arguments for format"); - return; - } - if (info->first_arg_num != 0) - { - cur_param = TREE_VALUE (params); - params = TREE_CHAIN (params); - ++arg_num; - if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) - != integer_type_node) - && - (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) - != unsigned_type_node)) - { - status_warning (status, "bitmap is not type int (arg %d)", arg_num); - } - } - } - if (*format_chars == 'D') - { - /* There should be an unsigned char * arg before the string arg. */ - if (params == 0) - { - status_warning (status, "too few arguments for format"); - return; - } - if (info->first_arg_num != 0) - { - tree cur_type; - cur_param = TREE_VALUE (params); - params = TREE_CHAIN (params); - ++arg_num; - cur_type = TREE_TYPE (cur_param); - if (TREE_CODE (cur_type) != POINTER_TYPE - || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type)) - != unsigned_char_type_node) - { - status_warning (status, - "ethernet address is not type unsigned char * (arg %d)", - arg_num); - } - } - } /* Read any format flags, but do not yet validate them beyond removing @@ -2062,4 +2014,55 @@ flag_chars[i] = 0; format_chars++; + } + } + } + + if (*format_chars == 'b') + { + /* There should be an int arg to control the string arg. */ + if (params == 0) + { + status_warning (status, "too few arguments for format"); + return; + } + if (info->first_arg_num != 0) + { + cur_param = TREE_VALUE (params); + params = TREE_CHAIN (params); + ++arg_num; + if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) + != integer_type_node) + && + (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) + != unsigned_type_node)) + { + status_warning (status, "bitmap is not type int (arg %d)", + arg_num); + } + } + } + if (*format_chars == 'D') + { + /* There should be an unsigned char * arg before the string arg. */ + if (params == 0) + { + status_warning (status, "too few arguments for format"); + return; + } + if (info->first_arg_num != 0) + { + tree cur_type; + + cur_param = TREE_VALUE (params); + params = TREE_CHAIN (params); + ++arg_num; + cur_type = TREE_TYPE (cur_param); + if (TREE_CODE (cur_type) != POINTER_TYPE + || TYPE_MAIN_VARIANT (TREE_TYPE (cur_type)) + != unsigned_char_type_node) + { + status_warning (status, + "ethernet address is not type unsigned char * (arg %d)", + arg_num); } } %%% Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020525195005.I6995-100000>