This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: More C99 format checking patches
- To: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Subject: Re: More C99 format checking patches
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Sun, 06 Aug 2000 11:58:10 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <Pine.SOL.4.21.0008052349560.5740-100000@orange.csi.cam.ac.uk>you
write:
> This patch makes some more C99-related printf/scanf format checking
> changes.
>
> Tree nodes are added for the signed type corresponding to size_t and
> the unsigned type corresponding to ptrdiff_t, since those are the
> types used by some C99 formats. (The C language signed type
> corresponding to size_t need not be the same as GCC's ssizetype, nor
> the same as ptrdiff_t; nor need the unsigned version of ptrdiff_t be
> the same as size_t, though size_t and ptrdiff_t do usually
> correspond.)
>
> Many miscellaneous fixes are made as detailed in the ChangeLog entry.
> A thorough testcase is added. The XFAILs relate to lack of genuine
> support for %j; I'll submit a PR for this for completeness.
>
> The pedantic checking is improved so that different signednesses of
> char are not accepted as pointer targets for formats such as %hhn
> (where the signedness is explicitly stated by the standard; %s may be
> any character type). While representations must agree, the programmer
> should use the correct type in these cases. This is the same
> principle as GCC having always warned (not just with -pedantic) for
> passing void * to %s even through the representations of the types are
> the same and char * to %p is OK.
>
> Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
>
> gcc/ChangeLog:
> 2000-08-05 Joseph S. Myers <jsm28@cam.ac.uk>
>
> * c-common.h (enum c_tree_index): Add CTI_SIGNED_SIZE_TYPE and
> CTI_UNSIGNED_PTRDIFF_TYPE.
> (signed_size_type_node): Define.
> (unsigned_ptrdiff_type_node): Define.
> * c-decl.c (init_decl_processing): Create the
> signed_size_type_node and unsigned_ptrdiff_type_node types.
> * c-common.c (T_SC): Define.
> (T_SST): Define.
> (T_UPD): Define.
> (print_char_table): Use T_SST for %zd, %zi, %zn. Use T_UPD for
> %to, %tu, %tx, %tX. Allow %hhn (T_SC). Add "c" to the flags for
> %s and %p.
> (scan_char_table): Use T_SC for %hhd, %hhi, %hhn. Use T_SST for
> %zd, %zi, %zn. Use T_UPD for %to, %tu, %tx, %tX. Add "c" to the
> flags for %c, %s and %[.
> (check_format_info): Only allow leniency for signedness of targets
> of character pointers (when pedantic) for formats flagged with
> "c", so for strings but not for %hh formats. When pedantic, don't
> allow character pointers to substitute for void pointers if a
> second level of indirection is present.
>
> gcc/testsuite/ChangeLog:
> 2000-08-05 Joseph S. Myers <jsm28@cam.ac.uk>
>
> * gcc.dg/c99-printf-1.c: New test.
These changes are fine. Please install them.
Thanks,
jeff