Fix PR39749 - Headers containing just #error harm __has_include.

This patch changes <experimental/foo> to use #warning instead of
is harmful to common feature detection idioms.

We should also consider only emitting the warning when __DEPRECATED is
defined, like we do in the <ext/foo> headers. Users may want to specify
"-Werror=-W#warnings" while still ignoring the libc++ warnings.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@350485 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier 2019-01-06 00:37:31 +00:00
parent 936dd3d1ff
commit 6420803549
24 changed files with 411 additions and 19 deletions

View File

@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ any -----------------------------------===//
//===------------------------------- any ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_ANY
#define _LIBCPP_EXPERIMENTAL_ANY
#error "<experimental/any> has been removed. Use <any> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/any> has been removed. Use <any> instead.")
#else
# warning "<experimental/any> has been removed. Use <any> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_ANY

View File

@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ chrono ---------------------------------===//
//===---------------------------- chrono ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
#define _LIBCPP_EXPERIMENTAL_CHRONO
#error "<experimental/chrono> has been removed. Use <chrono> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/chrono> has been removed. Use <chrono> instead.")
#else
# warning "<experimental/chrono> has been removed. Use <chrono> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_CHRONO

View File

@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
#define _LIBCPP_EXPERIMENTAL_NUMERIC
#error "<experimental/numeric> has been removed. Use <numeric> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/numeric> has been removed. Use <numeric> instead.")
#else
# warning "<experimental/numeric> has been removed. Use <numeric> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_NUMERIC

View File

@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
#define _LIBCPP_EXPERIMENTAL_OPTIONAL
#error "<experimental/optional> has been removed. Use <optional> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/optional> has been removed. Use <optional> instead.")
#else
# warning "<experimental/optional> has been removed. Use <optional> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL

View File

@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ ratio ---------------------------------===//
//===----------------------------- ratio ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_RATIO
#define _LIBCPP_EXPERIMENTAL_RATIO
#error "<experimental/ratio> has been removed. Use <ratio> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/ratio> has been removed. Use <ratio> instead.")
#else
# warning "<experimental/ratio> has been removed. Use <ratio> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_RATIO

View File

@ -3,9 +3,19 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_STRING_VIEW
#define _LIBCPP_EXPERIMENTAL_STRING_VIEW
#error "<experimental/string_view> has been removed. Use <string_view> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/string_view> has been removed. Use <string_view> instead.")
#else
# warning "<experimental/string_view> has been removed. Use <string_view> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_STRING_VIEW

View File

@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
#error "<experimental/system_error> has been removed. Use <system_error> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/system_error> has been removed. Use <system_error> instead.")
#else
# warning "<experimental/system_error> has been removed. Use <system_error> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR

View File

@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
#define _LIBCPP_EXPERIMENTAL_TUPLE
#error "<experimental/tuple> has been removed. Use <tuple> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/tuple> has been removed. Use <tuple> instead.")
#else
# warning "<experimental/tuple> has been removed. Use <tuple> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_TUPLE

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/system_error>
#include <experimental/system_error>
// expected-error@experimental/system_error:* {{"<experimental/system_error> has been removed. Use <system_error> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/system_error>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/system_error>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/numeric>
#include <experimental/numeric>
// expected-error@experimental/numeric:* {{"<experimental/numeric> has been removed. Use <numeric> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/numeric>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/numeric>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/string_view>
#include <experimental/string_view>
// expected-error@experimental/string_view:* {{"<experimental/string_view> has been removed. Use <string_view> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/string_view>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/string_view>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/any>
#include <experimental/any>
// expected-error@experimental/any:* {{"<experimental/any> has been removed. Use <any> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/any>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/any>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/optional>
#include <experimental/optional>
// expected-error@experimental/optional:* {{"<experimental/optional> has been removed. Use <optional> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/optional>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/optional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/ratio>
#include <experimental/ratio>
// expected-error@experimental/ratio:* {{"<experimental/ratio> has been removed. Use <ratio> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/ratio>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/ratio>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/chrono>
#include <experimental/chrono>
// expected-error@experimental/chrono:* {{"<experimental/chrono> has been removed. Use <chrono> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/chrono>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/chrono>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/tuple>
#include <experimental/tuple>
// expected-error@experimental/tuple:* {{"<experimental/tuple> has been removed. Use <tuple> instead."}}
int main() {}

View File

@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/tuple>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/tuple>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}