summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-04 23:47:21 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-04 23:47:21 +0000
commitf90d67e9e7d51314765c7f7f8983be266641d000 (patch)
treeef1505947ab10943f79a90f6527c3f16af6631dc
parent81c08ac38543d80cdcb2601ce2d00e72ab946490 (diff)
downloadgcc-f90d67e9e7d51314765c7f7f8983be266641d000.tar.gz
Test for C99 stdlib.h functions with -std=c++98
PR libstdc++/69626 * acinclude.m4 (GLIBCXX_ENABLE_C99): Check C99 stdlib.h functions with -std=c++98 and define _GLIBCXX98_USE_C99_STDLIB. * config.h.in: Regenerate. * configure: Regenerate. * testsuite/21_strings/c_strings/char/69626.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233161 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/acinclude.m429
-rw-r--r--libstdc++-v3/config.h.in4
-rwxr-xr-xlibstdc++-v3/configure89
-rw-r--r--libstdc++-v3/testsuite/21_strings/c_strings/char/69626.cc27
5 files changed, 156 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e7de4881bf7..b17e5f7ab5d 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,12 @@
2016-02-04 Jonathan Wakely <jwakely@redhat.com>
+ PR libstdc++/69626
+ * acinclude.m4 (GLIBCXX_ENABLE_C99): Check C99 stdlib.h functions
+ with -std=c++98 and define _GLIBCXX98_USE_C99_STDLIB.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+ * testsuite/21_strings/c_strings/char/69626.cc: New.
+
* doc/html/index.html: Regenerate.
* doc/xml/manual/containers.xml: Add cross-reference to Dual ABI.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 2d066701aec..057b58e054a 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1059,6 +1059,35 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
in <cstdio> in namespace std for C++98.])
fi
+ # Check for the existence in <stdlib.h> of lldiv_t, et. al.
+ AC_MSG_CHECKING([for ISO C99 support in <stdlib.h> for C++98])
+ AC_CACHE_VAL(glibcxx_cv_c99_stdlib_cxx98, [
+ GCC_TRY_COMPILE_OR_LINK(
+ [#include <stdlib.h>
+ volatile float f;
+ volatile long double ld;
+ volatile unsigned long long ll;
+ lldiv_t mydivt;],
+ [char* tmp;
+ f = strtof("gnu", &tmp);
+ ld = strtold("gnu", &tmp);
+ ll = strtoll("gnu", &tmp, 10);
+ ll = strtoull("gnu", &tmp, 10);
+ ll = llabs(10);
+ mydivt = lldiv(10,1);
+ ll = mydivt.quot;
+ ll = mydivt.rem;
+ ll = atoll("10");
+ _Exit(0);
+ ], [glibcxx_cv_c99_stdlib_cxx98=yes], [glibcxx_cv_c99_stdlib_cxx98=no])
+ ])
+ AC_MSG_RESULT($glibcxx_cv_c99_stdlib_cxx98)
+ if test x"$glibcxx_cv_c99_stdlib_cxx98" = x"yes"; then
+ AC_DEFINE(_GLIBCXX98_USE_C99_STDLIB, 1,
+ [Define if C99 functions or macros in <stdlib.h> should be imported
+ in <cstdlib> in namespace std for C++98.])
+ fi
+
# Check for the existence in <wchar.h> of wcstold, etc.
if test x"$ac_has_wchar_h" = xyes &&
test x"$ac_has_wctype_h" = xyes; then
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 5834154abf4..701d4796d38 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -771,6 +771,10 @@
<cstdio> in namespace std for C++98. */
#undef _GLIBCXX98_USE_C99_STDIO
+/* Define if C99 functions or macros in <stdlib.h> should be imported in
+ <cstdlib> in namespace std for C++98. */
+#undef _GLIBCXX98_USE_C99_STDLIB
+
/* Define if C99 functions or macros in <wchar.h> should be imported in
<cwchar> in namespace std for C++98. */
#undef _GLIBCXX98_USE_C99_WCHAR
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index efba47a1b04..a919a3e8bad 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -16970,6 +16970,95 @@ $as_echo "#define _GLIBCXX98_USE_C99_STDIO 1" >>confdefs.h
fi
+ # Check for the existence in <stdlib.h> of lldiv_t, et. al.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO C99 support in <stdlib.h> for C++98" >&5
+$as_echo_n "checking for ISO C99 support in <stdlib.h> for C++98... " >&6; }
+ if test "${glibcxx_cv_c99_stdlib_cxx98+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test x$gcc_no_link = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+ volatile float f;
+ volatile long double ld;
+ volatile unsigned long long ll;
+ lldiv_t mydivt;
+int
+main ()
+{
+char* tmp;
+ f = strtof("gnu", &tmp);
+ ld = strtold("gnu", &tmp);
+ ll = strtoll("gnu", &tmp, 10);
+ ll = strtoull("gnu", &tmp, 10);
+ ll = llabs(10);
+ mydivt = lldiv(10,1);
+ ll = mydivt.quot;
+ ll = mydivt.rem;
+ ll = atoll("10");
+ _Exit(0);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ glibcxx_cv_c99_stdlib_cxx98=yes
+else
+ glibcxx_cv_c99_stdlib_cxx98=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+ volatile float f;
+ volatile long double ld;
+ volatile unsigned long long ll;
+ lldiv_t mydivt;
+int
+main ()
+{
+char* tmp;
+ f = strtof("gnu", &tmp);
+ ld = strtold("gnu", &tmp);
+ ll = strtoll("gnu", &tmp, 10);
+ ll = strtoull("gnu", &tmp, 10);
+ ll = llabs(10);
+ mydivt = lldiv(10,1);
+ ll = mydivt.quot;
+ ll = mydivt.rem;
+ ll = atoll("10");
+ _Exit(0);
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ glibcxx_cv_c99_stdlib_cxx98=yes
+else
+ glibcxx_cv_c99_stdlib_cxx98=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_c99_stdlib_cxx98" >&5
+$as_echo "$glibcxx_cv_c99_stdlib_cxx98" >&6; }
+ if test x"$glibcxx_cv_c99_stdlib_cxx98" = x"yes"; then
+
+$as_echo "#define _GLIBCXX98_USE_C99_STDLIB 1" >>confdefs.h
+
+ fi
+
# Check for the existence in <wchar.h> of wcstold, etc.
if test x"$ac_has_wchar_h" = xyes &&
test x"$ac_has_wctype_h" = xyes; then
diff --git a/libstdc++-v3/testsuite/21_strings/c_strings/char/69626.cc b/libstdc++-v3/testsuite/21_strings/c_strings/char/69626.cc
new file mode 100644
index 00000000000..be3cdb32f97
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/c_strings/char/69626.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 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/>.
+
+// { dg-options "-std=gnu++98" }
+// { dg-do compile { target *-*-linux-gnu } }
+
+#include <cstdlib>
+
+long long test01()
+{
+ char* ep;
+ return std::strtoll("0", &ep, 10);
+}