2016-09-30 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/77795
+ * acinclude.m4 (GLIBCXX_CHECK_STDIO_PROTO): Use -std=gnu++11 to check
+ for gets.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+ * include/c_global/cstdio [!_GLIBCXX_HAVE_GETS] (gets): Only declare
+ for C++98 and C++11.
+ * include/c_std/cstdio [!_GLIBCXX_HAVE_GETS] (gets): Likewise.
+ * testsuite/27_io/headers/cstdio/functions_neg.cc: New test.
+
* doc/xml/manual/intro.xml: Document LWG 2192 changes.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/std_abs.h.
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
+ # Use C++11 because a conforming <stdio.h> won't define gets for C++14,
+ # and we don't need a declaration for C++14 anyway.
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=gnu++11"
AC_MSG_CHECKING([for gets declaration])
AC_CACHE_VAL(glibcxx_cv_gets, [
)])
if test $glibcxx_cv_gets = yes; then
- AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h>.])
+ AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in <stdio.h> before C++14.])
fi
AC_MSG_RESULT($glibcxx_cv_gets)
+ CXXFLAGS="$ac_save_CXXFLAGS"
AC_LANG_RESTORE
])
/* Define if _Unwind_GetIPInfo is available. */
#undef HAVE_GETIPINFO
-/* Define if gets is available in <stdio.h>. */
+/* Define if gets is available in <stdio.h> before C++14. */
#undef HAVE_GETS
/* Define to 1 if you have the `hypot' function. */
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+ # Use C++11 because a conforming <stdio.h> won't define gets for C++14,
+ # and we don't need a declaration for C++14 anyway.
+ ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS -std=gnu++11"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gets declaration" >&5
$as_echo_n "checking for gets declaration... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_gets" >&5
$as_echo "$glibcxx_cv_gets" >&6; }
+ CXXFLAGS="$ac_save_CXXFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
#ifndef _GLIBCXX_CSTDIO
#define _GLIBCXX_CSTDIO 1
-#ifndef _GLIBCXX_HAVE_GETS
+#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS)
extern "C" char* gets (char* __s) __attribute__((__deprecated__));
#endif
#include <bits/c++config.h>
#include <stdio.h>
-#ifndef _GLIBCXX_HAVE_GETS
+#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS)
extern "C" char* gets (char* __s) __attribute__((__deprecated__));
#endif
--- /dev/null
+// { dg-do compile { target c++14 } }
+
+// Copyright (C) 2007-2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstdio>
+
+namespace gnu
+{
+ using std::gets; // { dg-error "has not been declared" }
+}