[clang] 6273b5c - Roll back use of #warning for header deprecations

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu May 26 11:51:47 PDT 2022


Author: Aaron Ballman
Date: 2022-05-26T14:51:39-04:00
New Revision: 6273b5cbcdd346a833120c55061ab56f61827068

URL: https://github.com/llvm/llvm-project/commit/6273b5cbcdd346a833120c55061ab56f61827068
DIFF: https://github.com/llvm/llvm-project/commit/6273b5cbcdd346a833120c55061ab56f61827068.diff

LOG: Roll back use of #warning for header deprecations

e5ccd668019888de2704ae670da88a7be8cf7e0f and
5029dce492b3cf3ac191eda0b5bf268c3acac2e0 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.

Added: 
    

Modified: 
    clang/lib/Headers/stdbool.h
    clang/lib/Headers/stdnoreturn.h
    clang/test/Headers/stdbool.c
    clang/test/Sema/c2x-noreturn.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/stdbool.h b/clang/lib/Headers/stdbool.h
index ecf560218c3b5..f0e588532e166 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 <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

diff  --git a/clang/lib/Headers/stdnoreturn.h b/clang/lib/Headers/stdnoreturn.h
index 944e6904c7df6..7d19fa7b2f2b9 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 '<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 */

diff  --git a/clang/test/Headers/stdbool.c b/clang/test/Headers/stdbool.c
index 1ac94dc67a28f..a5189633c3596 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 <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

diff  --git a/clang/test/Sema/c2x-noreturn.c b/clang/test/Sema/c2x-noreturn.c
index 6c119736f6454..cc276877c2860 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 <stdnoreturn.h>
-#include <stdnoreturn.h> // c2x-warning at 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);
 


        


More information about the cfe-commits mailing list