From bcfb93e2e17168325111a0d4d51f045170ae0579 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 14 Feb 2005 08:52:24 +0000 Subject: include: 2005-02-08 Paolo Bonzini PR bootstrap/19818 * ansidecl.h (PARAMS): Guard from redefinition. libcpp: 2005-02-08 Paolo Bonzini PR bootstrap/19818 * configure.ac: Check for declaration of basename and getopt. * config.in: Regenerate. * configure: Regenerate. * internal.h (ustrcspn): New. * macro.c (create_iso_definition): Fix allocation of memory. (padding_token): Add cast to remove const-ness. * pch.c (cpp_read_state): Use ustrcspn. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@95003 138bc75d-0d04-0410-961f-82ee72b054a4 --- include/ChangeLog | 5 ++ include/ansidecl.h | 5 ++ libcpp/ChangeLog | 11 +++++ libcpp/config.in | 8 +++ libcpp/configure | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++ libcpp/configure.ac | 2 +- libcpp/internal.h | 9 ++++ libcpp/macro.c | 14 ++++-- libcpp/pch.c | 2 +- 9 files changed, 189 insertions(+), 7 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index 0a8c6016cea..da3aaa2f7c0 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2005-02-14 Paolo Bonzini + + PR bootstrap/19818 + * ansidecl.h (PARAMS): Guard from redefinition. + 2004-12-11 Ben Elliston * fibheap.h (struct fibnode): Only use unsigned long bitfields diff --git a/include/ansidecl.h b/include/ansidecl.h index 04c3a30bb53..2eeccf20351 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -149,7 +149,12 @@ So instead we use the macro below and test it against specific values. */ #define PTRCONST void *const #define LONG_DOUBLE long double +/* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in + a #ifndef. */ +#ifndef PARAMS #define PARAMS(ARGS) ARGS +#endif + #define VPARAMS(ARGS) ARGS #define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR) diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 35e5369137d..e1f9d1da90b 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,14 @@ +2005-02-14 Paolo Bonzini + + PR bootstrap/19818 + * configure.ac: Check for declaration of basename and getopt. + * config.in: Regenerate. + * configure: Regenerate. + * internal.h (ustrcspn): New. + * macro.c (create_iso_definition): Fix allocation of memory. + (padding_token): Add cast to remove const-ness. + * pch.c (cpp_read_state): Use ustrcspn. + 2005-02-08 Mike Stump * files.c (pchf_adder): Remove. diff --git a/libcpp/config.in b/libcpp/config.in index 8cf8cebcf3b..d7f67a609cf 100644 --- a/libcpp/config.in +++ b/libcpp/config.in @@ -26,6 +26,10 @@ */ #undef HAVE_DECL_ABORT +/* Define to 1 if you have the declaration of `basename', and to 0 if you + don't. */ +#undef HAVE_DECL_BASENAME + /* Define to 1 if you have the declaration of `errno', and to 0 if you don't. */ #undef HAVE_DECL_ERRNO @@ -46,6 +50,10 @@ you don't. */ #undef HAVE_DECL_FWRITE_UNLOCKED +/* Define to 1 if you have the declaration of `getopt', and to 0 if you don't. + */ +#undef HAVE_DECL_GETOPT + /* Define to 1 if you have the declaration of `putc_unlocked', and to 0 if you don't. */ #undef HAVE_DECL_PUTC_UNLOCKED diff --git a/libcpp/configure b/libcpp/configure index 604ed847d6f..b8c2c5a4cce 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -5065,6 +5065,76 @@ else _ACEOF +fi +echo "$as_me:$LINENO: checking whether basename is declared" >&5 +echo $ECHO_N "checking whether basename is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_basename+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef basename + char *p = (char *) basename; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_basename=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_basename=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_basename" >&5 +echo "${ECHO_T}$ac_cv_have_decl_basename" >&6 +if test $ac_cv_have_decl_basename = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_BASENAME 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_BASENAME 0 +_ACEOF + + fi echo "$as_me:$LINENO: checking whether errno is declared" >&5 echo $ECHO_N "checking whether errno is declared... $ECHO_C" >&6 @@ -5135,6 +5205,76 @@ else _ACEOF +fi +echo "$as_me:$LINENO: checking whether getopt is declared" >&5 +echo $ECHO_N "checking whether getopt is declared... $ECHO_C" >&6 +if test "${ac_cv_have_decl_getopt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef getopt + char *p = (char *) getopt; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_getopt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_have_decl_getopt=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_have_decl_getopt" >&5 +echo "${ECHO_T}$ac_cv_have_decl_getopt" >&6 +if test $ac_cv_have_decl_getopt = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETOPT 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETOPT 0 +_ACEOF + + fi echo "$as_me:$LINENO: checking whether putc_unlocked is declared" >&5 echo $ECHO_N "checking whether putc_unlocked is declared... $ECHO_C" >&6 diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 8a9a44986e8..b268d8d76bc 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -46,7 +46,7 @@ AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_FUNCS(putc_unlocked fputc_unlocked fputs_unlocked \ fwrite_unlocked fprintf_unlocked) -AC_CHECK_DECLS([abort, errno, putc_unlocked, fputc_unlocked, +AC_CHECK_DECLS([abort, basename, errno, getopt, putc_unlocked, fputc_unlocked, fputs_unlocked, fwrite_unlocked, fprintf_unlocked]) # Checks for library functions. diff --git a/libcpp/internal.h b/libcpp/internal.h index 9f39b21ec8e..74ae6c63d33 100644 --- a/libcpp/internal.h +++ b/libcpp/internal.h @@ -585,6 +585,9 @@ static inline unsigned char *uxstrdup (const unsigned char *); static inline unsigned char *ustrchr (const unsigned char *, int); static inline int ufputs (const unsigned char *, FILE *); +/* Use a const char for the second parameter since it is usually a literal. */ +static inline int ustrcspn (const unsigned char *, const char *); + static inline int ustrcmp (const unsigned char *s1, const unsigned char *s2) { @@ -597,6 +600,12 @@ ustrncmp (const unsigned char *s1, const unsigned char *s2, size_t n) return strncmp ((const char *)s1, (const char *)s2, n); } +static inline int +ustrcspn (const unsigned char *s1, const char *s2) +{ + return strcspn ((const char *)s1, s2); +} + static inline size_t ustrlen (const unsigned char *s1) { diff --git a/libcpp/macro.c b/libcpp/macro.c index e3824cbe5af..e118a5c72c1 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -910,7 +910,10 @@ padding_token (cpp_reader *pfile, const cpp_token *source) cpp_token *result = _cpp_temp_token (pfile); result->type = CPP_PADDING; - result->val.source = source; + + /* Data in GCed data structures cannot be made const so far, so we + need a cast here. */ + result->val.source = (cpp_token *) source; result->flags = 0; return result; } @@ -1416,10 +1419,11 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro) /* Success. Commit or allocate the parameter array. */ if (pfile->hash_table->alloc_subobject) { - cpp_token *tokns = pfile->hash_table->alloc_subobject - (sizeof (cpp_token) * macro->paramc); - memcpy (tokns, macro->params, sizeof (cpp_token) * macro->paramc); - macro->params = tokns; + cpp_hashnode **params = pfile->hash_table->alloc_subobject + (sizeof (cpp_hashnode *) * macro->paramc); + memcpy (params, macro->params, + sizeof (cpp_hashnode *) * macro->paramc); + macro->params = params; } else BUFF_FRONT (pfile->a_buff) = (uchar *) ¯o->params[macro->paramc]; diff --git a/libcpp/pch.c b/libcpp/pch.c index 292132139d2..8de5c01a8fc 100644 --- a/libcpp/pch.c +++ b/libcpp/pch.c @@ -653,7 +653,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f, size_t namelen; uchar *defn; - namelen = strcspn (data->defns[i], "( \n"); + namelen = ustrcspn (data->defns[i], "( \n"); h = cpp_lookup (r, data->defns[i], namelen); defn = data->defns[i] + namelen; -- cgit v1.2.3