[clang] [clang-tools-extra] [Clang] Add support for the C `defer` TS (PR #162848)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 10 06:37:56 PST 2025
================
@@ -0,0 +1,22 @@
+/*===---- stddefer.h - Standard header for 'defer' -------------------------===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __CLANG_STDDEFER_H
+#define __CLANG_STDDEFER_H
+
+/* Provide 'defer' if '_Defer' is supported and update the predefined
+ macro accordingly. */
+#if defined __STDC_DEFER_TS25755__ && __STDC_DEFER_TS25755__ == 1
+#undef __STDC_DEFER_TS25755__
----------------
AaronBallman wrote:
Do we need to do this dance? I would have assumed this header would be (with a header guard):
```
#ifdef __STDC_DEFER_TS25755__
#define __STDC_VERSION_STDDEFER_H__ 202602L
#define defer _Defer
#endif
```
We don't want to redefine `__STDC_DEFER_TS25755__` to 2 because we're not providing `defer` as a keyword, only `_Defer`. And we don't need to worry about working with other implementations because this header is tied to Clang itself, so we don't need to worry about the value being `2` instead.
https://github.com/llvm/llvm-project/pull/162848
More information about the cfe-commits
mailing list