as per the bugzilla log
tested x86/linux
-benjamin
2012-03-01 Benjamin Kosnik <b...@redhat.com>
Ramana Radhakrishnan <ram...@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.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index fe37a91..56711c0 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1809,6 +1809,35 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_PROTO], [
])
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
AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index c788cb0..c4aa305 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -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
@@ -39,4 +39,11 @@
#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
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 49de141..f04563e 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -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.
diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio
index 049704d..d11743a 100644
--- a/libstdc++-v3/include/c_global/cstdio
+++ b/libstdc++-v3/include/c_global/cstdio
@@ -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
@@ -46,6 +46,10 @@
#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
diff --git a/libstdc++-v3/include/c_std/cstdio b/libstdc++-v3/include/c_std/cstdio
index 510f599..1588fc9 100644
--- a/libstdc++-v3/include/c_std/cstdio
+++ b/libstdc++-v3/include/c_std/cstdio
@@ -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
@@ -45,6 +45,10 @@
#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