Skip to content

Commit 271c513

Browse files
committed
[libc++] Split libc++-specific tests for the frozen headers
1 parent cf6ae06 commit 271c513

File tree

921 files changed

+84519
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

921 files changed

+84519
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
// REQUIRES: target={{.*}}-apple-{{.*}}
10+
// UNSUPPORTED: c++03
11+
12+
// This test ensures that libc++ supports being compiled with modules enabled and with
13+
// -Wnon-modular-include-in-module. This effectively checks that we don't include any
14+
// non-modular header from the library.
15+
//
16+
// Since most underlying platforms are not modularized properly, this test currently only
17+
// works on Apple platforms.
18+
19+
// ADDITIONAL_COMPILE_FLAGS: -Wnon-modular-include-in-module -Wsystem-headers-in-module=std -fmodules -fcxx-modules
20+
21+
#include <vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
// <algorithm>
10+
11+
// template <class RandomAccessIterator>
12+
// void
13+
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
14+
//
15+
// template <class RandomAccessIterator, class RandomNumberGenerator>
16+
// void
17+
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
18+
// RandomNumberGenerator& rand);
19+
20+
//
21+
// In C++17, random_shuffle has been removed.
22+
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
23+
// is defined before including <algorithm>, then random_shuffle will be restored.
24+
25+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
26+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
27+
28+
#include <algorithm>
29+
#include <cstddef>
30+
#include <vector>
31+
32+
#include "test_macros.h"
33+
34+
struct gen
35+
{
36+
std::ptrdiff_t operator()(std::ptrdiff_t n)
37+
{
38+
return n-1;
39+
}
40+
};
41+
42+
43+
int main(int, char**)
44+
{
45+
std::vector<int> v;
46+
std::random_shuffle(v.begin(), v.end());
47+
gen r;
48+
std::random_shuffle(v.begin(), v.end(), r);
49+
50+
return 0;
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
// <algorithm>
10+
11+
// template <class RandomAccessIterator>
12+
// void
13+
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
14+
//
15+
// template <class RandomAccessIterator, class RandomNumberGenerator>
16+
// void
17+
// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
18+
// RandomNumberGenerator& rand);
19+
20+
// UNSUPPORTED: c++03, c++11
21+
22+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
23+
24+
#include <algorithm>
25+
#include <cstddef>
26+
27+
#include "test_macros.h"
28+
29+
struct gen
30+
{
31+
std::ptrdiff_t operator()(std::ptrdiff_t n)
32+
{
33+
return n-1;
34+
}
35+
};
36+
37+
38+
void f() {
39+
int v[1] = {1};
40+
std::random_shuffle(&v[0], &v[1]); // expected-warning {{'random_shuffle<int *>' is deprecated}}
41+
gen r;
42+
std::random_shuffle(&v[0], &v[1], r); // expected-warning {{'random_shuffle<int *, gen &>' is deprecated}}
43+
}

0 commit comments

Comments
 (0)