Skip to content

Commit 11bd19a

Browse files
authored
[libc][assert] define __STDC_VERSION_ASSERT_H__ (llvm#87592)
Fixes llvm#87561
1 parent 63b6efe commit 11bd19a

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

libc/include/assert.h.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "__llvm-libc-common.h"
10+
#include "llvm-libc-macros/assert-macros.h"
1011

1112
// This file may be usefully included multiple times to change assert()'s
1213
// definition based on NDEBUG.

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
3131
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
3232
endif()
3333

34+
add_macro_header(
35+
assert_macros
36+
HDR
37+
assert-macros.h
38+
)
39+
3440
add_macro_header(
3541
generic_error_number_macros
3642
HDR
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Definition of macros to be used with assert functions -------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __LLVM_LIBC_MACROS_ASSERT_MACROS_H
10+
#define __LLVM_LIBC_MACROS_ASSERT_MACROS_H
11+
12+
#define __STDC_VERSION_ASSERT_H__ 202311L
13+
14+
#endif // __LLVM_LIBC_MACROS_ASSERT_MACROS_H

libc/test/include/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
add_custom_target(libc_include_tests)
22

3+
add_libc_test(
4+
assert_test
5+
SUITE
6+
libc_include_tests
7+
SRCS
8+
assert_test.cpp
9+
DEPENDS
10+
libc.include.llvm-libc-macros.assert_macros
11+
)
12+
313
add_libc_test(
414
sys_queue_test
515
SUITE

libc/test/include/assert_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===-- Unittests for assert ----------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDSList-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "include/llvm-libc-macros/assert-macros.h"
10+
#include "test/UnitTest/Test.h"
11+
12+
TEST(LlvmLibcAssertTest, VersionMacro) {
13+
// 7.2p3 an integer constant expression with a value equivalent to 202311L.
14+
EXPECT_EQ(__STDC_VERSION_ASSERT_H__, 202311L);
15+
}

0 commit comments

Comments
 (0)