From: Jonathan Wakely Date: Fri, 30 Sep 2016 18:28:53 +0000 (+0100) Subject: libstdc++/77795 Only declare ::gets for C++98 and C++11 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=36105dbdab0fe4a20682d6d8efc6da7fceccef07;p=gcc.git 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f73e62e4789..be41539547d 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,15 @@ 2016-09-30 Jonathan Wakely + 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. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index ffead7dfd4c..d0ee45fb49b 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2153,6 +2153,10 @@ AC_DEFUN([GLIBCXX_CHECK_STDIO_PROTO], [ AC_LANG_SAVE AC_LANG_CPLUSPLUS + # Use C++11 because a conforming 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 .]) + AC_DEFINE(HAVE_GETS, 1, [Define if gets is available in before C++14.]) fi AC_MSG_RESULT($glibcxx_cv_gets) + CXXFLAGS="$ac_save_CXXFLAGS" AC_LANG_RESTORE ]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 2ab6e0d6a49..63996709ad4 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -183,7 +183,7 @@ /* Define if _Unwind_GetIPInfo is available. */ #undef HAVE_GETIPINFO -/* Define if gets is available in . */ +/* Define if gets is available in before C++14. */ #undef HAVE_GETS /* Define to 1 if you have the `hypot' function. */ diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index f7b424b9e63..09b73b85891 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -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 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' diff --git a/libstdc++-v3/include/c_global/cstdio b/libstdc++-v3/include/c_global/cstdio index 920d109bcb8..86d524f96a6 100644 --- a/libstdc++-v3/include/c_global/cstdio +++ b/libstdc++-v3/include/c_global/cstdio @@ -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 diff --git a/libstdc++-v3/include/c_std/cstdio b/libstdc++-v3/include/c_std/cstdio index a4119ba6c64..549004c0a16 100644 --- a/libstdc++-v3/include/c_std/cstdio +++ b/libstdc++-v3/include/c_std/cstdio @@ -44,7 +44,7 @@ #include #include -#ifndef _GLIBCXX_HAVE_GETS +#if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS) extern "C" char* gets (char* __s) __attribute__((__deprecated__)); #endif diff --git a/libstdc++-v3/testsuite/27_io/headers/cstdio/functions_neg.cc b/libstdc++-v3/testsuite/27_io/headers/cstdio/functions_neg.cc new file mode 100644 index 00000000000..f9e5f86ed37 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/headers/cstdio/functions_neg.cc @@ -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 +// . + +#include + +namespace gnu +{ + using std::gets; // { dg-error "has not been declared" } +}