From 642080354947e0606992aa091ce5e1b4e1e4179d Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sun, 6 Jan 2019 00:37:31 +0000 Subject: [PATCH] Fix PR39749 - Headers containing just #error harm __has_include. This patch changes 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 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 --- include/experimental/any | 18 ++++++++++++---- include/experimental/chrono | 18 ++++++++++++---- include/experimental/numeric | 12 ++++++++++- include/experimental/optional | 12 ++++++++++- include/experimental/ratio | 18 ++++++++++++---- include/experimental/string_view | 16 +++++++++++--- include/experimental/system_error | 12 ++++++++++- include/experimental/tuple | 12 ++++++++++- .../syserr/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../diagnostics/syserr/version.pass.cpp | 21 +++++++++++++++++++ .../numeric.ops/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../numerics/numeric.ops/version.pass.cpp | 21 +++++++++++++++++++ .../string.view/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../strings/string.view/version.pass.cpp | 21 +++++++++++++++++++ .../utilities/any/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../utilities/any/version.pass.cpp | 21 +++++++++++++++++++ .../optional/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../utilities/optional/version.pass.cpp | 21 +++++++++++++++++++ .../ratio/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../utilities/ratio/version.pass.cpp | 21 +++++++++++++++++++ .../time/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../utilities/time/version.pass.cpp | 21 +++++++++++++++++++ .../tuple/use_header_warning.fail.cpp | 18 ++++++++++++++++ .../utilities/tuple/version.pass.cpp | 21 +++++++++++++++++++ 24 files changed, 411 insertions(+), 19 deletions(-) create mode 100644 test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/diagnostics/syserr/version.pass.cpp create mode 100644 test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp create mode 100644 test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/strings/string.view/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/any/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/optional/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/ratio/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/time/version.pass.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp create mode 100644 test/libcxx/experimental/utilities/tuple/version.pass.cpp diff --git a/include/experimental/any b/include/experimental/any index 1dcdd0f25..d9c953425 100644 --- a/include/experimental/any +++ b/include/experimental/any @@ -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 " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_ANY diff --git a/include/experimental/chrono b/include/experimental/chrono index 591cf7160..30c7e4a9d 100644 --- a/include/experimental/chrono +++ b/include/experimental/chrono @@ -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 " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_CHRONO diff --git a/include/experimental/numeric b/include/experimental/numeric index 14a664011..19c65313f 100644 --- a/include/experimental/numeric +++ b/include/experimental/numeric @@ -7,5 +7,15 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC +#define _LIBCPP_EXPERIMENTAL_NUMERIC -#error " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_NUMERIC diff --git a/include/experimental/optional b/include/experimental/optional index d68cefdf6..6eb4a2618 100644 --- a/include/experimental/optional +++ b/include/experimental/optional @@ -7,5 +7,15 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL +#define _LIBCPP_EXPERIMENTAL_OPTIONAL -#error " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL diff --git a/include/experimental/ratio b/include/experimental/ratio index 9c2bf2e46..52c12004d 100644 --- a/include/experimental/ratio +++ b/include/experimental/ratio @@ -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 " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_RATIO diff --git a/include/experimental/string_view b/include/experimental/string_view index f13bff54d..100bdfe72 100644 --- a/include/experimental/string_view +++ b/include/experimental/string_view @@ -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 " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_STRING_VIEW diff --git a/include/experimental/system_error b/include/experimental/system_error index 7937357fa..1cf84ee01 100644 --- a/include/experimental/system_error +++ b/include/experimental/system_error @@ -7,5 +7,15 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR +#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR -#error " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR diff --git a/include/experimental/tuple b/include/experimental/tuple index 1f37a6293..6d71bb559 100644 --- a/include/experimental/tuple +++ b/include/experimental/tuple @@ -7,5 +7,15 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +#ifndef _LIBCPP_EXPERIMENTAL_TUPLE +#define _LIBCPP_EXPERIMENTAL_TUPLE -#error " has been removed. Use instead." +#include <__config> + +#ifdef _LIBCPP_WARNING +_LIBCPP_WARNING(" has been removed. Use instead.") +#else +# warning " has been removed. Use instead." +#endif + +#endif // _LIBCPP_EXPERIMENTAL_TUPLE diff --git a/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp b/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp new file mode 100644 index 000000000..074a9c58c --- /dev/null +++ b/test/libcxx/experimental/diagnostics/syserr/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/system_error:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp b/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp new file mode 100644 index 000000000..c4fb9593a --- /dev/null +++ b/test/libcxx/experimental/diagnostics/syserr/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp b/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp new file mode 100644 index 000000000..32fd0527d --- /dev/null +++ b/test/libcxx/experimental/numerics/numeric.ops/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/numeric:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp b/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp new file mode 100644 index 000000000..37ac584a7 --- /dev/null +++ b/test/libcxx/experimental/numerics/numeric.ops/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp b/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp new file mode 100644 index 000000000..64f737420 --- /dev/null +++ b/test/libcxx/experimental/strings/string.view/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/string_view:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/strings/string.view/version.pass.cpp b/test/libcxx/experimental/strings/string.view/version.pass.cpp new file mode 100644 index 000000000..417982e36 --- /dev/null +++ b/test/libcxx/experimental/strings/string.view/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp new file mode 100644 index 000000000..0bcda7056 --- /dev/null +++ b/test/libcxx/experimental/utilities/any/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/any:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/any/version.pass.cpp b/test/libcxx/experimental/utilities/any/version.pass.cpp new file mode 100644 index 000000000..bc37d8b4d --- /dev/null +++ b/test/libcxx/experimental/utilities/any/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp new file mode 100644 index 000000000..1711d2f03 --- /dev/null +++ b/test/libcxx/experimental/utilities/optional/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/optional:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/optional/version.pass.cpp b/test/libcxx/experimental/utilities/optional/version.pass.cpp new file mode 100644 index 000000000..ef011bbe4 --- /dev/null +++ b/test/libcxx/experimental/utilities/optional/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp new file mode 100644 index 000000000..d9a01337a --- /dev/null +++ b/test/libcxx/experimental/utilities/ratio/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/ratio:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/ratio/version.pass.cpp b/test/libcxx/experimental/utilities/ratio/version.pass.cpp new file mode 100644 index 000000000..8ebb347a4 --- /dev/null +++ b/test/libcxx/experimental/utilities/ratio/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp new file mode 100644 index 000000000..9f3d679fc --- /dev/null +++ b/test/libcxx/experimental/utilities/time/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/chrono:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/time/version.pass.cpp b/test/libcxx/experimental/utilities/time/version.pass.cpp new file mode 100644 index 000000000..5544a3f0e --- /dev/null +++ b/test/libcxx/experimental/utilities/time/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {} diff --git a/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp b/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp new file mode 100644 index 000000000..520e9fbb4 --- /dev/null +++ b/test/libcxx/experimental/utilities/tuple/use_header_warning.fail.cpp @@ -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 + +// + +#include + +// expected-error@experimental/tuple:* {{" has been removed. Use instead."}} + +int main() {} diff --git a/test/libcxx/experimental/utilities/tuple/version.pass.cpp b/test/libcxx/experimental/utilities/tuple/version.pass.cpp new file mode 100644 index 000000000..c7c9e5728 --- /dev/null +++ b/test/libcxx/experimental/utilities/tuple/version.pass.cpp @@ -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. +// +//===----------------------------------------------------------------------===// + +// + +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-W#warnings" +#endif +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() {}