From 6273b5cbcdd346a833120c55061ab56f61827068 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 26 May 2022 14:43:28 -0400 Subject: [PATCH] Roll back use of #warning for header deprecations e5ccd668019888de2704ae670da88a7be8cf7e0f and 5029dce492b3cf3ac191eda0b5bf268c3acac2e0 added deprecation warnings to the and 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. --- clang/lib/Headers/stdbool.h | 6 +++--- clang/lib/Headers/stdnoreturn.h | 4 +++- clang/test/Headers/stdbool.c | 9 +-------- clang/test/Sema/c2x-noreturn.c | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/clang/lib/Headers/stdbool.h b/clang/lib/Headers/stdbool.h index ecf560218c3b..f0e588532e16 100644 --- a/clang/lib/Headers/stdbool.h +++ b/clang/lib/Headers/stdbool.h @@ -13,9 +13,9 @@ #define __bool_true_false_are_defined 1 #if __STDC_VERSION__ > 201710L -#if !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS) -#warning "the 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 diff --git a/clang/lib/Headers/stdnoreturn.h b/clang/lib/Headers/stdnoreturn.h index 944e6904c7df..7d19fa7b2f2b 100644 --- a/clang/lib/Headers/stdnoreturn.h +++ b/clang/lib/Headers/stdnoreturn.h @@ -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 '' 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 */ diff --git a/clang/test/Headers/stdbool.c b/clang/test/Headers/stdbool.c index 1ac94dc67a28..a5189633c359 100644 --- a/clang/test/Headers/stdbool.c +++ b/clang/test/Headers/stdbool.c @@ -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 @@ -8,12 +7,6 @@ // CHECK-C11: #define false 0 // CHECK-C11: #define true 1 -// CHECK-C2X: warning "the header is deprecated // CHECK-C2X-NOT: #define bool // CHECK-C2X-NOT: #define true -// CHECK-C2X-NOT: #define falsea - -// CHECK-C2X-CRT-NOT: warning "the 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 diff --git a/clang/test/Sema/c2x-noreturn.c b/clang/test/Sema/c2x-noreturn.c index 6c119736f645..cc276877c286 100644 --- a/clang/test/Sema/c2x-noreturn.c +++ b/clang/test/Sema/c2x-noreturn.c @@ -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 -#include // c2x-warning@stdnoreturn.h:* {{the '' header is deprecated in C2x; either use the '_Noreturn' keyword or the '[[noreturn]]' attribute}} +#include [[noreturn]] void func6(void);