[libc-commits] [libc] 11bd19a - [libc][assert] define __STDC_VERSION_ASSERT_H__ (#87592)
via libc-commits
libc-commits at lists.llvm.org
Wed Apr 24 13:01:20 PDT 2024
Author: aniplcc
Date: 2024-04-24T13:01:16-07:00
New Revision: 11bd19a7a25b291af61b6c06cb249b567c116d0e
URL: https://github.com/llvm/llvm-project/commit/11bd19a7a25b291af61b6c06cb249b567c116d0e
DIFF: https://github.com/llvm/llvm-project/commit/11bd19a7a25b291af61b6c06cb249b567c116d0e.diff
LOG: [libc][assert] define __STDC_VERSION_ASSERT_H__ (#87592)
Fixes #87561
Added:
libc/include/llvm-libc-macros/assert-macros.h
libc/test/include/assert_test.cpp
Modified:
libc/include/assert.h.def
libc/include/llvm-libc-macros/CMakeLists.txt
libc/test/include/CMakeLists.txt
Removed:
################################################################################
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index e006133a76542a..15077e53e2ca48 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "__llvm-libc-common.h"
+#include "llvm-libc-macros/assert-macros.h"
// This file may be usefully included multiple times to change assert()'s
// definition based on NDEBUG.
diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index 382cb8ee417e16..68ba110aec80f1 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -31,6 +31,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()
+add_macro_header(
+ assert_macros
+ HDR
+ assert-macros.h
+)
+
add_macro_header(
generic_error_number_macros
HDR
diff --git a/libc/include/llvm-libc-macros/assert-macros.h b/libc/include/llvm-libc-macros/assert-macros.h
new file mode 100644
index 00000000000000..44e14543d8562e
--- /dev/null
+++ b/libc/include/llvm-libc-macros/assert-macros.h
@@ -0,0 +1,14 @@
+//===-- Definition of macros to be used with assert functions -------------===//
+//
+// 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 __LLVM_LIBC_MACROS_ASSERT_MACROS_H
+#define __LLVM_LIBC_MACROS_ASSERT_MACROS_H
+
+#define __STDC_VERSION_ASSERT_H__ 202311L
+
+#endif // __LLVM_LIBC_MACROS_ASSERT_MACROS_H
diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt
index 8d8dff53169f6a..03c31855e352ba 100644
--- a/libc/test/include/CMakeLists.txt
+++ b/libc/test/include/CMakeLists.txt
@@ -1,5 +1,15 @@
add_custom_target(libc_include_tests)
+add_libc_test(
+ assert_test
+ SUITE
+ libc_include_tests
+ SRCS
+ assert_test.cpp
+ DEPENDS
+ libc.include.llvm-libc-macros.assert_macros
+)
+
add_libc_test(
sys_queue_test
SUITE
diff --git a/libc/test/include/assert_test.cpp b/libc/test/include/assert_test.cpp
new file mode 100644
index 00000000000000..78709bbcdd5941
--- /dev/null
+++ b/libc/test/include/assert_test.cpp
@@ -0,0 +1,15 @@
+//===-- Unittests for assert ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "include/llvm-libc-macros/assert-macros.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcAssertTest, VersionMacro) {
+ // 7.2p3 an integer constant expression with a value equivalent to 202311L.
+ EXPECT_EQ(__STDC_VERSION_ASSERT_H__, 202311L);
+}
More information about the libc-commits
mailing list