Skip to content

Commit 132fd34

Browse files
committed
Fix build on Windows in C++26 mode
1 parent 1d2c365 commit 132fd34

File tree

7 files changed

+34
-19
lines changed

7 files changed

+34
-19
lines changed

libcxx/include/fstream

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ _LIBCPP_PUSH_MACROS
218218
_LIBCPP_BEGIN_NAMESPACE_STD
219219

220220
# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)
221-
_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file);
221+
_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept;
222222
# endif
223223

224224
template <class _CharT, class _Traits>

libcxx/test/std/input.output/file.streams/fstreams/filebuf.members/native_handle.assert.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <fstream>
2222

23-
#include "../native_handle_test_helpers.h"
23+
#include "../native_handle_assert_test_helpers.h"
2424

2525
int main(int, char**) {
2626
test_native_handle_assertion<std::basic_filebuf<char>>();

libcxx/test/std/input.output/file.streams/fstreams/fstream.members/native_handle.assert.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <fstream>
2222

23-
#include "../native_handle_test_helpers.h"
23+
#include "../native_handle_assert_test_helpers.h"
2424

2525
int main(int, char**) {
2626
test_native_handle_assertion<std::basic_fstream<char>>();

libcxx/test/std/input.output/file.streams/fstreams/ifstream.members/native_handle.assert.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <fstream>
2222

23-
#include "../native_handle_test_helpers.h"
23+
#include "../native_handle_assert_test_helpers.h"
2424

2525
int main(int, char**) {
2626
test_native_handle_assertion<std::basic_ifstream<char>>();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===----------------------------------------------------------------------===//
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 TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_ASSERT_TEST_HELPERS_H
10+
#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_ASSERT_TEST_HELPERS_H
11+
12+
#if !__has_include(<unistd.h>) || !__has_include(<sys/wait.h>)
13+
# error "Requires UNIX headers"
14+
#endif
15+
16+
#include "check_assertion.h"
17+
18+
template <typename StreamT>
19+
inline void test_native_handle_assertion() {
20+
StreamT f;
21+
22+
// non-const
23+
TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened");
24+
// const
25+
TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be opened");
26+
}
27+
28+
#endif // TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_ASSERT_TEST_HELPERS_H

libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@
2525
#endif
2626

2727
#include "platform_support.h"
28-
#include "test_macros.h"
2928
#include "types.h"
3029

3130
#if TEST_STD_VER >= 26
3231

33-
# include "check_assertion.h"
34-
3532
inline bool is_handle_valid(NativeHandleT handle) {
3633
# if defined(_WIN32)
3734
BY_HANDLE_FILE_INFORMATION fileInformation;
38-
return GetFileInformationByHandle(handle, &fileInformation));
35+
return GetFileInformationByHandle(handle, &fileInformation);
3936
# elif __has_include(<unistd.h>) // POSIX
4037
return fcntl(handle, F_GETFL) != -1 || errno != EBADF;
4138
# else
@@ -75,16 +72,6 @@ inline void test_native_handle() {
7572
}
7673
}
7774

78-
template <typename StreamT>
79-
inline void test_native_handle_assertion() {
80-
StreamT f;
81-
82-
// non-const
83-
TEST_LIBCPP_ASSERT_FAILURE(f.native_handle(), "File must be opened");
84-
// const
85-
TEST_LIBCPP_ASSERT_FAILURE(std::as_const(f).native_handle(), "File must be opened");
86-
}
87-
8875
template <typename StreamT>
8976
inline void test_native_handle_type() {
9077
static_assert(std::is_trivially_copyable_v<typename StreamT::native_handle_type>);

libcxx/test/std/input.output/file.streams/fstreams/ofstream.members/native_handle.assert.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <fstream>
2222

23-
#include "../native_handle_test_helpers.h"
23+
#include "../native_handle_assert_test_helpers.h"
2424

2525
int main(int, char**) {
2626
test_native_handle_assertion<std::basic_ofstream<char>>();

0 commit comments

Comments
 (0)