From fbee6d3164ed509ebe08222264f352fecf1c9824 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 24 Oct 2014 21:56:40 +0100 Subject: [PATCH] C++11 explicitly forbids macros for bool, true and false. gcc: * ginclude/stdbool.h: Do not define bool, true or false in C++11. libstdc++-v3: * testsuite/18_support/headers/cstdbool/macros.cc: New. From-SVN: r216679 --- gcc/ChangeLog | 4 ++ gcc/ginclude/stdbool.h | 6 ++- libstdc++-v3/ChangeLog | 4 ++ .../18_support/headers/cstdbool/macros.cc | 37 +++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a81559adaa6..145ce9db3d7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-10-24 Jonathan Wakely + + * ginclude/stdbool.h: Do not define bool, true or false in C++11. + 2014-10-24 Charles Baylis * config/aarch64/arm_neon.h (__LD2_LANE_FUNC): Rewrite using builtins, diff --git a/gcc/ginclude/stdbool.h b/gcc/ginclude/stdbool.h index f4e802fe4d6..a06f17f2460 100644 --- a/gcc/ginclude/stdbool.h +++ b/gcc/ginclude/stdbool.h @@ -36,11 +36,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #else /* __cplusplus */ -/* Supporting in C++ is a GCC extension. */ +/* Supporting _Bool in C++ is a GCC extension. */ #define _Bool bool + +#if __cplusplus < 201103L +/* Defining these macros in C++98 is a GCC extension. */ #define bool bool #define false false #define true true +#endif #endif /* __cplusplus */ diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c2f185921f1..27e31bb7126 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,7 @@ +2014-10-24 Jonathan Wakely + + * testsuite/18_support/headers/cstdbool/macros.cc: New. + 2014-10-24 Paolo Carlini * include/bits/atomic_base.h: Avoid including . diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc new file mode 100644 index 00000000000..df2e24568ff --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc @@ -0,0 +1,37 @@ +// { dg-do compile } +// { dg-options "-std=gnu++11" } + +// Copyright (C) 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 +// 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 + +#ifndef __bool_true_false_are_defined +# error "The header fails to define a macro named __bool_true_false_are_defined" +#endif + +#ifdef bool +# error "The header defines a macro named bool" +#endif + +#ifdef true +# error "The header defines a macro named true" +#endif + +#ifdef false +# error "The header defines a macro named false" +#endif -- 2.30.2