Skip to content

Commit 6273b5c

Browse files
committed
Roll back use of #warning for header deprecations
e5ccd66 and 5029dce 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.
1 parent 7c13ae6 commit 6273b5c

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

clang/lib/Headers/stdbool.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#define __bool_true_false_are_defined 1
1414

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

clang/lib/Headers/stdnoreturn.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
followed by code that writes [[noreturn]]. The issue with such code is not
2222
with the attribute, or the use of 'noreturn', but the inclusion of the
2323
header. */
24-
#warning "the '<stdnoreturn.h>' header is deprecated in C2x; either use the '_Noreturn' keyword or the '[[noreturn]]' attribute"
24+
/* FIXME: We should be issuing a deprecation warning here, but cannot yet due
25+
* to system headers which include this header file unconditionally.
26+
*/
2527
#endif
2628

2729
#endif /* __STDNORETURN_H */

clang/test/Headers/stdbool.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c11 -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C11 %s
22
// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C2X %s
3-
// 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
43

54
#include <stdbool.h>
65

76
// CHECK-C11: #define bool _Bool
87
// CHECK-C11: #define false 0
98
// CHECK-C11: #define true 1
109

11-
// CHECK-C2X: warning "the <stdbool.h> header is deprecated
1210
// CHECK-C2X-NOT: #define bool
1311
// CHECK-C2X-NOT: #define true
14-
// CHECK-C2X-NOT: #define falsea
15-
16-
// CHECK-C2X-CRT-NOT: warning "the <stdbool.h> header is deprecated
17-
// CHECK-C2X-CRT-NOT: #define bool
18-
// CHECK-C2X-CRT-NOT: #define true
19-
// CHECK-C2X-CRT-NOT: #define false
12+
// CHECK-C2X-NOT: #define false

clang/test/Sema/c2x-noreturn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _Noreturn void func1(void); // ok, using the function specifier
3636
[[_Noreturn]] void func3(void); // all-warning {{the '[[_Noreturn]]' attribute spelling is deprecated in C2x; use '[[noreturn]]' instead}}
3737

3838
// Test the behavior of including <stdnoreturn.h>
39-
#include <stdnoreturn.h> // [email protected]:* {{the '<stdnoreturn.h>' header is deprecated in C2x; either use the '_Noreturn' keyword or the '[[noreturn]]' attribute}}
39+
#include <stdnoreturn.h>
4040

4141
[[noreturn]] void func6(void);
4242

0 commit comments

Comments
 (0)