Roll back use of #warning for header deprecations

e5ccd66801 and
5029dce492 added deprecation warnings to
the <stdbool.h> and <stdnoreturn.h> headers, respectively, because the
headers are deprecated in C2x.

However, there are system headers that include these headers
unconditionally, and #warning diagnostics within system headers are
shown to users instead of suppressed, which means these deprecation
warnings are being triggered in circumstances that users have no
control over except to disable all the warnings through the
_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS macro or other means.

This removes the problematic #warning uses until we find a more
palatable solution.
This commit is contained in:
Aaron Ballman 2022-05-26 14:43:28 -04:00
parent 7c13ae6490
commit 6273b5cbcd
4 changed files with 8 additions and 13 deletions

View File

@ -13,9 +13,9 @@
#define __bool_true_false_are_defined 1
#if __STDC_VERSION__ > 201710L
#if !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
#warning "the <stdbool.h> header is deprecated in C2x"
#endif /* !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS) */
/* FIXME: We should be issuing a deprecation warning here, but cannot yet due
* to system headers which include this header file unconditionally.
*/
#elif !defined(__cplusplus)
#define bool _Bool
#define true 1

View File

@ -21,7 +21,9 @@
followed by code that writes [[noreturn]]. The issue with such code is not
with the attribute, or the use of 'noreturn', but the inclusion of the
header. */
#warning "the '<stdnoreturn.h>' header is deprecated in C2x; either use the '_Noreturn' keyword or the '[[noreturn]]' attribute"
/* FIXME: We should be issuing a deprecation warning here, but cannot yet due
* to system headers which include this header file unconditionally.
*/
#endif
#endif /* __STDNORETURN_H */

View File

@ -1,6 +1,5 @@
// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c11 -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C11 %s
// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C2X %s
// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS %s 2>&1 | FileCheck --check-prefix=CHECK-C2X-CRT %s
#include <stdbool.h>
@ -8,12 +7,6 @@
// CHECK-C11: #define false 0
// CHECK-C11: #define true 1
// CHECK-C2X: warning "the <stdbool.h> header is deprecated
// CHECK-C2X-NOT: #define bool
// CHECK-C2X-NOT: #define true
// CHECK-C2X-NOT: #define falsea
// CHECK-C2X-CRT-NOT: warning "the <stdbool.h> header is deprecated
// CHECK-C2X-CRT-NOT: #define bool
// CHECK-C2X-CRT-NOT: #define true
// CHECK-C2X-CRT-NOT: #define false
// CHECK-C2X-NOT: #define false

View File

@ -36,7 +36,7 @@ _Noreturn void func1(void); // ok, using the function specifier
[[_Noreturn]] void func3(void); // all-warning {{the '[[_Noreturn]]' attribute spelling is deprecated in C2x; use '[[noreturn]]' instead}}
// Test the behavior of including <stdnoreturn.h>
#include <stdnoreturn.h> // c2x-warning@stdnoreturn.h:* {{the '<stdnoreturn.h>' header is deprecated in C2x; either use the '_Noreturn' keyword or the '[[noreturn]]' attribute}}
#include <stdnoreturn.h>
[[noreturn]] void func6(void);