diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-30 18:29:24 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-30 18:29:24 +0000 |
commit | c81bdb40f857f1db8b00c0ea62ed6b8f7b9c2cac (patch) | |
tree | e32f4c0f13dc0bfbf8bcf035ed732f8bbd76829e /libstdc++-v3 | |
parent | 1969d1bc6b10522a5abdb3dda73ede2765a905aa (diff) | |
download | gcc-c81bdb40f857f1db8b00c0ea62ed6b8f7b9c2cac.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@240674 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/acinclude.m4 | 7 | ||||
-rw-r--r-- | libstdc++-v3/config.h.in | 2 | ||||
-rwxr-xr-x | libstdc++-v3/configure | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/c_global/cstdio | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/c_std/cstdio | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/headers/cstdio/functions_neg.cc | 25 |
7 files changed, 49 insertions, 4 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d3f3fcd5269..d02668823bb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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. + PR libstdc++/77801 * include/experimental/numeric: Include <numeric>. (__abs): Define. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 4769f14d12f..43bece13686 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 <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 ]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 701d4796d38..0a84fba7322 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -180,7 +180,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. */ diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index efb382c7edf..bbbcd5d7ce0 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -18175,6 +18175,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; } @@ -18209,6 +18213,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 <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 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 +// <http://www.gnu.org/licenses/>. + +#include <cstdio> + +namespace gnu +{ + using std::gets; // { dg-error "has not been declared" } +} |