Skip to content

[libc][assert] define __STDC_VERSION_ASSERT_H__ #87592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/include/assert.h.def
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions libc/include/llvm-libc-macros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions libc/include/llvm-libc-macros/assert-macros.h
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions libc/test/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions libc/test/include/assert_test.cpp
Original file line number Diff line number Diff line change
@@ -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);
}