mirror of
https://github.com/gcc-mirror/gcc.git
synced 2025-08-15 22:56:43 +00:00

Although <ciso646> was removed from C++20, it was not formally deprecated in C++17. In contrast, <ctgmath>, <cstdalign>, etc. were formally deprecated in C++17 before being removed in C++20. Due to the widespread convention of including <ciso646> to detect implementation-specific macros (such as _GLIBCXX_RELEASE) it causes quite a lot of noise to issue deprecation warnings in C++17 mode. The recommendation to include <version> instead does work for recent compilers, even in C++17 mode, but isn't portable to older compilers that don't provide <version> yet (e.g. GCC 8). There are also potential objections to including <version> pre-C++20 when it wasn't defined by the standard. I don't have much sympathy for this position, because including <ciso646> for implementation-specific macros wasn't part of the C++17 standard either. It's no more non-standard to rely on <version> being present and defining those macros than to rely on <ciso646> defining them, and __has_include can be used to detect whether <version> is present. However, <ciso646> is being used in the wild by popular libraries like Abseil and we can't change versions of those that have already been released. This removes the #warning in <ciso646> for C++17 mode, so that we only emit diagnostics for C++20 and later. With this change, including <ciso646> in C++20 or later gives an error if _GLIBCXX_USE_DEPRECATED is defined to zero, otherwise a warning if -Wdeprecated is enabled, otherwise no diagnostic is given. This also adds "@since C++11 (removed in C++20)" to the Doxygen @file comments in all the relevant headers. The test for <ciso646> needs to be updated to no longer expect a warning for c++17_only. A new test is added to ensure that we get a warning instead of an error when -D_GLIBCXX_USE_DEPRECATED=0 is not used. libstdc++-v3/ChangeLog: PR libstdc++/120187 * include/c_global/ciso646: Only give deprecated warning for C++20 and later. * include/c_global/ccomplex: Add @since to Doxygen comment. * include/c_global/cstdalign: Likewise. * include/c_global/cstdbool: Likewise. * include/c_global/ctgmath: Likewise. * testsuite/18_support/headers/ciso646/macros.cc: Remove dg-warning for c++17_only effective target. * testsuite/18_support/headers/ciso646/macros-2.cc: New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
// <cstdbool> -*- C++ -*-
|
|
|
|
// Copyright (C) 2007-2025 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.
|
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
/** @file include/cstdbool
|
|
* This is a Standard C++ Library header.
|
|
*
|
|
* @since C++11 (removed in C++20)
|
|
*/
|
|
|
|
#ifndef _GLIBCXX_CSTDBOOL
|
|
#define _GLIBCXX_CSTDBOOL 1
|
|
|
|
#ifdef _GLIBCXX_SYSHDR
|
|
#pragma GCC system_header
|
|
#endif
|
|
|
|
#if __cplusplus < 201103L
|
|
# include <bits/c++0x_warning.h>
|
|
#else
|
|
# include <bits/c++config.h>
|
|
# if _GLIBCXX_HAVE_STDBOOL_H
|
|
# include <stdbool.h>
|
|
# endif
|
|
# if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
|
|
# error "<cstdbool> is not a standard header in C++20, remove the #include"
|
|
# elif __cplusplus >= 201703L && defined __DEPRECATED
|
|
# pragma GCC diagnostic push
|
|
# pragma GCC diagnostic ignored "-Wc++23-extensions"
|
|
# warning "<cstdbool> is deprecated in C++17, remove the #include"
|
|
# pragma GCC diagnostic pop
|
|
# endif
|
|
#endif
|
|
|
|
#endif
|