re PR libstdc++/51785 (gets not anymore declared)
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 2 Mar 2012 07:13:55 +0000 (07:13 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 2 Mar 2012 07:13:55 +0000 (07:13 +0000)
2012-03-01  Benjamin Kosnik  <bkoz@redhat.com>
            Ramana Radhakrishnan <ramana@gcc.gnu.org>

PR libstdc++/51785
* acinclude.m4 (GLIBCXX_CHECK_STDIO_PROTO): New.
* configure.ac: Call it.
* configure: Regenerate.
* config.h.in: Same.
* config/os/gnu-linux/os_defines.h: Conditionally undefine
_GLIBCXX_HAVE_GETS.
* include/c_global/cstdio: Conditionally declare deprecated gets.
* include/c_std/cstdio: Same.

Co-Authored-By: Ramana Radhakrishnan <ramana@gcc.gnu.org>
From-SVN: r184774

libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config.h.in
libstdc++-v3/config/os/gnu-linux/os_defines.h
libstdc++-v3/configure
libstdc++-v3/configure.ac
libstdc++-v3/include/c_global/cstdio
libstdc++-v3/include/c_std/cstdio

index 112ac3d170f720300e564ade12a12878d5ed0df8..dba9a79bedf1eab441bdd26f55afc33a1a7a9763 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-01  Benjamin Kosnik  <bkoz@redhat.com>
+            Ramana Radhakrishnan <ramana@gcc.gnu.org>
+
+       PR libstdc++/51785
+       * acinclude.m4 (GLIBCXX_CHECK_STDIO_PROTO): New.
+       * configure.ac: Call it.
+       * configure: Regenerate.
+       * config.h.in: Same.
+       * config/os/gnu-linux/os_defines.h: Conditionally undefine
+       _GLIBCXX_HAVE_GETS.
+       * include/c_global/cstdio: Conditionally declare deprecated gets.
+       * include/c_std/cstdio: Same.
+
 2012-03-01  Michael Spertus  <mike_spertus@symantec.com>
 
        * include/tr2/type_traits (typelist): To __reflection_typelist.
index fe37a91a397931a05c91782d7dad9c757ab2c577..56711c06475c4579ccb8352d5216eacc0d133c9d 100644 (file)
@@ -1808,6 +1808,35 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_PROTO], [
   AC_LANG_RESTORE
 ])
 
+dnl
+dnl Check whether required C++ overloads are present in <stdio.h>.
+dnl
+AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
+
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+
+  AC_MSG_CHECKING([for gets declaration])
+  AC_CACHE_VAL(glibcxx_cv_gets, [
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+         [#include <stdio.h>
+          namespace test 
+          {
+              using ::gets;
+          }
+       ])],
+       [glibcxx_cv_gets=yes],
+       [glibcxx_cv_gets=no]
+      )])
+
+  if test $glibcxx_cv_gets = yes; then
+    AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h>.])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_gets)
+
+  AC_LANG_RESTORE
+])
+
 dnl
 dnl Check whether macros, etc are present for <system_error>
 dnl
index 378ddabb3f24a017a6cb294bf881b3cf108cd044..4dea92b6d14ac0fc50943f4b45b6d208d05e71b7 100644 (file)
 /* Define if _Unwind_GetIPInfo is available. */
 #undef HAVE_GETIPINFO
 
+/* Define if gets is available in <stdio.h>. */
+#undef HAVE_GETS
+
 /* Define to 1 if you have the `hypot' function. */
 #undef HAVE_HYPOT
 
index c788cb0710dedfe2d87fc376ba31d81133adf98d..c4aa305487db7fb02133cc1edf5173abb533f2dd 100644 (file)
@@ -1,6 +1,6 @@
 // Specific definitions for GNU/Linux  -*- C++ -*-
 
-// Copyright (C) 2000, 2001, 2002, 2003, 2009, 2010
+// Copyright (C) 2000, 2001, 2002, 2003, 2009, 2010, 2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 
 #include <features.h>
 
+// Provide a declaration for the possibly deprecated gets function, as
+// glibc 2.15 and later does not declare gets for ISO C11 when
+// __GNU_SOURCE is defined.
+#if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE)
+# undef _GLIBCXX_HAVE_GETS
+#endif
+
 #endif
index d3444e050999335801267698730e4c020f923df2..9e5731f8c55395ac431197e0f45574eb995efaa9 100755 (executable)
@@ -17415,6 +17415,56 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gets declaration" >&5
+$as_echo_n "checking for gets declaration... " >&6; }
+  if test "${glibcxx_cv_gets+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+          namespace test
+          {
+              using ::gets;
+          }
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  glibcxx_cv_gets=yes
+else
+  glibcxx_cv_gets=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+  if test $glibcxx_cv_gets = yes; then
+
+$as_echo "#define HAVE_GETS 1" >>confdefs.h
+
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_gets" >&5
+$as_echo "$glibcxx_cv_gets" >&6; }
+
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EOWNERDEAD" >&5
 $as_echo_n "checking for EOWNERDEAD... " >&6; }
 if test "${glibcxx_cv_system_error1+set}" = set; then :
index 49de141be7b753dec091c9dc35ca698b146b58bd..f04563ea7586a847f1c7e7fdda5710a329d14478 100644 (file)
@@ -136,6 +136,7 @@ GLIBCXX_ENABLE_WERROR([yes])
 # Checks for operating systems support that doesn't require linking.
 GLIBCXX_CHECK_MATH_PROTO
 GLIBCXX_CHECK_STDLIB_PROTO
+GLIBCXX_CHECK_STDIO_PROTO
 GLIBCXX_CHECK_SYSTEM_ERROR
 
 # For the streamoff typedef.
index 049704d83b9031138eda3f13c56b1c9b80474646..d11743a349da97dd2e0242da2ab869c0322d58de 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*- forwarding header.
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2008, 2009, 2010
+// 2006, 2007, 2008, 2009, 2010, 2012
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 #ifndef _GLIBCXX_CSTDIO
 #define _GLIBCXX_CSTDIO 1
 
+#ifndef _GLIBCXX_HAVE_GETS
+extern "C" extern char* gets (char* __s) __attribute__((deprecated));
+#endif
+
 // Get rid of those macros defined in <stdio.h> in lieu of real functions.
 #undef clearerr
 #undef fclose
@@ -67,7 +71,6 @@
 #undef ftell
 #undef fwrite
 #undef getc
-#undef getchar
 #undef gets
 #undef perror
 #undef printf
index 510f599d876d4992e070baca0d6f2767564fab13..1588fc9e55b501559746296979d9ebf739e68d02 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*- forwarding header.
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2009, 2010  Free Software Foundation, Inc.
+// 2009, 2010, 2012  Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 #include <bits/c++config.h>
 #include <stdio.h>
 
+#ifndef _GLIBCXX_HAVE_GETS
+extern "C" extern char* gets (char* __s) __attribute__((deprecated));
+#endif
+
 // Get rid of those macros defined in <stdio.h> in lieu of real functions.
 #undef clearerr
 #undef fclose