]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/52764 (Including <cstdint> after <stdint.h> fails to define limit macros)
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 6 Oct 2012 23:06:04 +0000 (23:06 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 6 Oct 2012 23:06:04 +0000 (23:06 +0000)
2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52764
* ginclude/stdint-wrap.h: In C++11 if __STDC_HOSTED__ define
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS.
* ginclude/stdint-gcc.h: In C++11 unconditionally define
limit and constant macros.

/testsuite
2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52764
* g++.dg/cpp0x/stdint.C: New.

/libstdc++-v3
2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52764
* include/c_global/cstdint: Remove __STDC_LIMIT_MACROS and
__STDC_CONSTANT_MACROS related macros.

From-SVN: r192174

gcc/ChangeLog
gcc/ginclude/stdint-gcc.h
gcc/ginclude/stdint-wrap.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/stdint.C [new file with mode: 0644]
libstdc++-v3/ChangeLog
libstdc++-v3/include/c_global/cstdint

index a198490318bb4a0ad90e9bfcce8a6529bb3c8fcd..c80b5e0770001b6e9e09092d16701fad2590d81d 100644 (file)
@@ -1,3 +1,11 @@
+2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52764
+       * ginclude/stdint-wrap.h: In C++11 if __STDC_HOSTED__ define
+       __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS.
+       * ginclude/stdint-gcc.h: In C++11 unconditionally define
+       limit and constant macros.
+
 2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/54249
index 22780a15efac305c661b5241f6980cd5522592ab..64b389930c9e3c0ec94b5e0ed59bc0eaeb9f856d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -91,7 +91,8 @@ typedef __UINTPTR_TYPE__ uintptr_t;
 typedef __INTMAX_TYPE__ intmax_t;
 typedef __UINTMAX_TYPE__ uintmax_t;
 
-#if !defined __cplusplus || defined __STDC_LIMIT_MACROS
+#if (!defined __cplusplus || __cplusplus >= 201103L \
+     || defined __STDC_LIMIT_MACROS)
 
 /* 7.18.2 Limits of specified-width integer types */
 
@@ -229,9 +230,11 @@ typedef __UINTMAX_TYPE__ uintmax_t;
 #undef WINT_MIN
 #define WINT_MIN __WINT_MIN__
 
-#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
+#endif /* (!defined __cplusplus || __cplusplus >= 201103L
+          || defined __STDC_LIMIT_MACROS)  */
 
-#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
+#if (!defined __cplusplus || __cplusplus >= 201103L \
+     || defined __STDC_CONSTANT_MACROS)
 
 #undef INT8_C
 #define INT8_C(c) __INT8_C(c)
@@ -254,6 +257,7 @@ typedef __UINTMAX_TYPE__ uintmax_t;
 #undef UINTMAX_C
 #define UINTMAX_C(c) __UINTMAX_C(c)
 
-#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
+#endif /* (!defined __cplusplus || __cplusplus >= 201103L
+          || defined __STDC_CONSTANT_MACROS) */
 
 #endif /* _GCC_STDINT_H */
index e45f8198b97e147c326311964c531dd04bd3e4f4..83b6f70c83795dca60b1a6355fbc643af81637d1 100644 (file)
@@ -1,5 +1,11 @@
 #ifndef _GCC_WRAP_STDINT_H
 #if __STDC_HOSTED__
+# if defined __cplusplus && __cplusplus >= 201103L
+#  undef __STDC_LIMIT_MACROS
+#  define __STDC_LIMIT_MACROS
+#  undef __STDC_CONSTANT_MACROS
+#  define __STDC_CONSTANT_MACROS
+# endif
 # include_next <stdint.h>
 #else
 # include "stdint-gcc.h"
index 24a28b0b5faff6f049c76a9ba253c728adfc6fec..9114655313571517127a9a18e695c177b175d9d2 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52764
+       * g++.dg/cpp0x/stdint.C: New.
+
 2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/54249
diff --git a/gcc/testsuite/g++.dg/cpp0x/stdint.C b/gcc/testsuite/g++.dg/cpp0x/stdint.C
new file mode 100644 (file)
index 0000000..434d458
--- /dev/null
@@ -0,0 +1,135 @@
+// PR c++/52764
+// { dg-require-effective-target stdint_types }
+// { dg-do compile { target c++11 } }
+
+#include <stdint.h>
+
+#ifdef __INT8_TYPE__
+# if (!defined INT8_MAX \
+      || !defined INT8_MIN)
+# error
+# endif
+#endif
+#ifdef __UINT8_TYPE__
+# if !defined UINT8_MAX
+# error
+# endif
+#endif
+#ifdef __INT16_TYPE__
+# if (!defined INT16_MAX \
+      || !defined INT16_MIN)
+# error
+# endif
+#endif
+#ifdef __UINT16_TYPE__
+# if !defined UINT16_MAX
+# error
+# endif
+#endif
+#ifdef __INT32_TYPE__
+# if (!defined INT32_MAX \
+      || !defined INT32_MIN)
+# error
+# endif
+#endif
+#ifdef __UINT32_TYPE__
+# if !defined UINT32_MAX
+# error
+# endif
+#endif
+#ifdef __INT64_TYPE__
+# if (!defined INT64_MAX \
+      || !defined INT64_MIN)
+# error
+# endif
+#endif
+#ifdef __UINT64_TYPE__
+# if !defined UINT64_MAX
+# error
+# endif
+#endif
+
+#if (!defined INT_LEAST8_MAX \
+     || !defined INT_LEAST8_MIN        \
+     || !defined UINT_LEAST8_MAX \
+     || !defined INT_LEAST16_MAX \
+     || !defined INT_LEAST16_MIN \
+     || !defined UINT_LEAST16_MAX \
+     || !defined INT_LEAST32_MAX \
+     || !defined INT_LEAST32_MIN \
+     || !defined UINT_LEAST32_MAX \
+     || !defined INT_LEAST64_MAX \
+     || !defined INT_LEAST64_MIN \
+     || !defined UINT_LEAST64_MAX)
+#error
+#endif
+
+#if (!defined INT_FAST8_MAX \
+     || !defined INT_FAST8_MIN \
+     || !defined UINT_FAST8_MAX \
+     || !defined INT_FAST16_MAX        \
+     || !defined INT_FAST16_MIN        \
+     || !defined UINT_FAST16_MAX \
+     || !defined INT_FAST32_MAX        \
+     || !defined INT_FAST32_MIN        \
+     || !defined UINT_FAST32_MAX \
+     || !defined INT_FAST64_MAX        \
+     || !defined INT_FAST64_MIN        \
+     || !defined UINT_FAST64_MAX)
+#error
+#endif
+
+#ifdef __INTPTR_TYPE__
+# if (!defined INTPTR_MAX \
+      || !defined INTPTR_MIN)
+# error
+# endif
+#endif
+#ifdef __UINTPTR_TYPE__
+# if !defined UINTPTR_MAX
+# error
+# endif
+#endif
+
+#if (!defined INTMAX_MAX \
+     || !defined INTMAX_MIN \
+     || !defined UINTMAX_MAX)
+#error
+#endif
+
+#if (!defined PTRDIFF_MAX \
+     || !defined PTRDIFF_MIN)
+#error
+#endif
+
+#if (!defined SIG_ATOMIC_MAX \
+     || !defined SIG_ATOMIC_MIN)
+#error
+#endif
+
+#if !defined SIZE_MAX
+#error
+#endif
+
+#if (!defined WCHAR_MAX \
+     || !defined WCHAR_MIN)
+#error
+#endif
+
+#if (!defined WINT_MAX \
+     || !defined WINT_MIN)
+#error
+#endif
+
+#if (!defined INT8_C \
+     || !defined INT16_C \
+     || !defined INT32_C \
+     || !defined INT64_C \
+     || !defined UINT8_C \
+     || !defined UINT16_C \
+     || !defined UINT32_C \
+     || !defined UINT64_C \
+     || !defined INTMAX_C \
+     || !defined UINTMAX_C)
+#error
+#endif
index 2dee02e817d56988564b1195c8eeaadbef1039bf..6f6da57af4ee91a19ec965f0bffad6feddbeeb03 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-06  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52764
+       * include/c_global/cstdint: Remove __STDC_LIMIT_MACROS and
+       __STDC_CONSTANT_MACROS related macros.
+
 2012-10-06  Joe Seymour  <jseymour@codesourcery.com>
 
        * include/tr2/dynamic_bitset: Fix cxxabi_forced.h include path.
index ce8143ea2bd4035c40c6eee331b8b5104e3a2166..5ebee3bd793875d421e247ff3c70a530c3f8b291 100644 (file)
@@ -1,6 +1,6 @@
 // <cstdint> -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007-2012 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
 
 #include <bits/c++config.h>
 
-// For 8.22.1/1 (see C99, Notes 219, 220, 222)
 #if _GLIBCXX_HAVE_STDINT_H
-# ifndef __STDC_LIMIT_MACROS
-#  define _UNDEF__STDC_LIMIT_MACROS
-#  define __STDC_LIMIT_MACROS
-# endif
-# ifndef __STDC_CONSTANT_MACROS
-#  define _UNDEF__STDC_CONSTANT_MACROS
-#  define __STDC_CONSTANT_MACROS
-# endif
 # include <stdint.h>
-# ifdef _UNDEF__STDC_LIMIT_MACROS
-#  undef __STDC_LIMIT_MACROS
-#  undef _UNDEF__STDC_LIMIT_MACROS
-# endif
-# ifdef _UNDEF__STDC_CONSTANT_MACROS
-#  undef __STDC_CONSTANT_MACROS
-#  undef _UNDEF__STDC_CONSTANT_MACROS
-# endif
 #endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1