inclhack.def (glibc_strncpy): New fix.
fixincludes: * inclhack.def (glibc_strncpy): New fix. * fixincl.x: Regenerate. * tests/base/bits/string2.h: Update. gcc/testsuite: * gcc.dg/strncpy-fix-1.c: New test. From-SVN: r157717
This commit is contained in:
parent
5e599ebb7d
commit
6f5db5f7e9
6 changed files with 99 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
|||
2010-03-24 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* inclhack.def (glibc_strncpy): New fix.
|
||||
* fixincl.x: Regenerate.
|
||||
* tests/base/bits/string2.h: Update.
|
||||
|
||||
2010-03-23 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR target/40722
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
*
|
||||
* DO NOT EDIT THIS FILE (fixincl.x)
|
||||
*
|
||||
* It has been AutoGen-ed March 11, 2010 at 08:08:36 PM by AutoGen 5.10.1
|
||||
* It has been AutoGen-ed Wednesday March 24, 2010 at 02:21:16 PM PDT
|
||||
* From the definitions inclhack.def
|
||||
* and the template file fixincl
|
||||
*/
|
||||
/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Mar 11 20:08:36 PST 2010
|
||||
/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Mar 24 14:21:16 PDT 2010
|
||||
*
|
||||
* You must regenerate it. Use the ./genfixes script.
|
||||
*
|
||||
|
@ -15,7 +15,7 @@
|
|||
* certain ANSI-incompatible system header files which are fixed to work
|
||||
* correctly with ANSI C and placed in a directory that GNU C will search.
|
||||
*
|
||||
* This file contains 205 fixup descriptions.
|
||||
* This file contains 206 fixup descriptions.
|
||||
*
|
||||
* See README for more information.
|
||||
*
|
||||
|
@ -2845,6 +2845,45 @@ static const char* apzGlibc_StdintPatch[] = {
|
|||
# define UINT16_C\\(c\\)\tc ## U",
|
||||
(char*)NULL };
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Description of Glibc_Strncpy fix
|
||||
*/
|
||||
tSCC zGlibc_StrncpyName[] =
|
||||
"glibc_strncpy";
|
||||
|
||||
/*
|
||||
* File name selection pattern
|
||||
*/
|
||||
tSCC zGlibc_StrncpyList[] =
|
||||
"bits/string2.h\0";
|
||||
/*
|
||||
* Machine/OS name selection pattern
|
||||
*/
|
||||
#define apzGlibc_StrncpyMachs (const char**)NULL
|
||||
|
||||
/*
|
||||
* content bypass pattern - skip fix if pattern found
|
||||
*/
|
||||
tSCC zGlibc_StrncpyBypass0[] =
|
||||
"__builtin_strncpy";
|
||||
|
||||
#define GLIBC_STRNCPY_TEST_CT 1
|
||||
static tTestDesc aGlibc_StrncpyTests[] = {
|
||||
{ TT_NEGREP, zGlibc_StrncpyBypass0, (regex_t*)NULL }, };
|
||||
|
||||
/*
|
||||
* Fix Command Arguments for Glibc_Strncpy
|
||||
*/
|
||||
static const char* apzGlibc_StrncpyPatch[] = {
|
||||
"format",
|
||||
"# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)",
|
||||
"# define strncpy([^\n\
|
||||
]*\\\\\n\
|
||||
)*[^\n\
|
||||
]*",
|
||||
(char*)NULL };
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* Description of Glibc_Tgmath fix
|
||||
|
@ -6345,7 +6384,7 @@ tSCC zSolaris_Math_8List[] =
|
|||
* content selection pattern - do fix if pattern found
|
||||
*/
|
||||
tSCC zSolaris_Math_8Select0[] =
|
||||
"@\\(#\\)math_c99.h[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
|
||||
"@\\(#\\)math_c99\\.h[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
|
||||
|
||||
/*
|
||||
* content bypass pattern - skip fix if pattern found
|
||||
|
@ -8356,9 +8395,9 @@ static const char* apzX11_SprintfPatch[] = {
|
|||
*
|
||||
* List of all fixes
|
||||
*/
|
||||
#define REGEX_COUNT 245
|
||||
#define REGEX_COUNT 246
|
||||
#define MACH_LIST_SIZE_LIMIT 181
|
||||
#define FIX_COUNT 205
|
||||
#define FIX_COUNT 206
|
||||
|
||||
/*
|
||||
* Enumerate the fixes
|
||||
|
@ -8431,6 +8470,7 @@ typedef enum {
|
|||
GLIBC_C99_INLINE_4_FIXIDX,
|
||||
GLIBC_MUTEX_INIT_FIXIDX,
|
||||
GLIBC_STDINT_FIXIDX,
|
||||
GLIBC_STRNCPY_FIXIDX,
|
||||
GLIBC_TGMATH_FIXIDX,
|
||||
GNU_TYPES_FIXIDX,
|
||||
HP_INLINE_FIXIDX,
|
||||
|
@ -8907,6 +8947,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
|
|||
GLIBC_STDINT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
|
||||
aGlibc_StdintTests, apzGlibc_StdintPatch, 0 },
|
||||
|
||||
{ zGlibc_StrncpyName, zGlibc_StrncpyList,
|
||||
apzGlibc_StrncpyMachs,
|
||||
GLIBC_STRNCPY_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
|
||||
aGlibc_StrncpyTests, apzGlibc_StrncpyPatch, 0 },
|
||||
|
||||
{ zGlibc_TgmathName, zGlibc_TgmathList,
|
||||
apzGlibc_TgmathMachs,
|
||||
GLIBC_TGMATH_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
|
||||
|
|
|
@ -1598,6 +1598,28 @@ fix = {
|
|||
};
|
||||
|
||||
|
||||
/* Some versions of glibc have a version of bits/string2.h that
|
||||
produces "value computed is not used" warnings from strncpy; fix
|
||||
this definition by using __builtin_strncpy instead as in newer
|
||||
versions. */
|
||||
fix = {
|
||||
hackname = glibc_strncpy;
|
||||
files = bits/string2.h;
|
||||
bypass = "__builtin_strncpy";
|
||||
c_fix = format;
|
||||
c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
|
||||
c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
|
||||
test_text = <<-EOT
|
||||
# define strncpy(dest, src, n) \
|
||||
(__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
|
||||
? (strlen (src) + 1 >= ((size_t) (n)) \\
|
||||
? (char *) memcpy (dest, src, n) \\
|
||||
: strncpy (dest, src, n)) \\
|
||||
: strncpy (dest, src, n)))
|
||||
EOT;
|
||||
|
||||
};
|
||||
|
||||
/* glibc's tgmath.h relies on an expression that is not an integer
|
||||
constant expression being treated as it was by GCC 4.4 and
|
||||
earlier. */
|
||||
|
|
|
@ -16,3 +16,8 @@
|
|||
# define __STRING_INLINE extern __inline
|
||||
# endif
|
||||
#endif /* GLIBC_C99_INLINE_3_CHECK */
|
||||
|
||||
|
||||
#if defined( GLIBC_STRNCPY_CHECK )
|
||||
# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)
|
||||
#endif /* GLIBC_STRNCPY_CHECK */
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2010-03-24 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* gcc.dg/strncpy-fix-1.c: New test.
|
||||
|
||||
2010-03-24 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk>
|
||||
|
||||
PR testsuite/41609
|
||||
|
|
11
gcc/testsuite/gcc.dg/strncpy-fix-1.c
Normal file
11
gcc/testsuite/gcc.dg/strncpy-fix-1.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* Test that use of strncpy does not result in a "value computed is
|
||||
not used" warning. */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall" } */
|
||||
|
||||
#include <string.h>
|
||||
void
|
||||
f (char *s)
|
||||
{
|
||||
strncpy (s, "::", 2);
|
||||
}
|
Loading…
Add table
Reference in a new issue