libstdc++/77795 Only declare ::gets for C++98 and C++11

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.

From-SVN: r240672
This commit is contained in:
Jonathan Wakely 2016-09-30 19:28:53 +01:00 committed by Jonathan Wakely
parent b2861325a9
commit 36105dbdab
7 changed files with 49 additions and 4 deletions

View File

@ -1,5 +1,15 @@
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.

View File

@ -2153,6 +2153,10 @@ AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
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, [
@ -2168,10 +2172,11 @@ AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [
)])
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
])

View File

@ -183,7 +183,7 @@
/* 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. */

View File

@ -18176,6 +18176,10 @@ 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
# 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; }
@ -18210,6 +18214,7 @@ $as_echo "#define HAVE_GETS 1" >>confdefs.h
{ $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'

View File

@ -44,7 +44,7 @@
#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

View File

@ -44,7 +44,7 @@
#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

View File

@ -0,0 +1,25 @@
// { 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" }
}