Skip to content
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

[libc++] Make .verify.cpp tests more robust against changing headers #128703

Merged
merged 1 commit into from
Feb 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// UNSUPPORTED: no-threads
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

// This test verifies that <stdatomic.h> redirects to <atomic>.

// Before C++23, <stdatomic.h> can be included after <atomic>, but including it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,8 @@

// UNSUPPORTED: no-wide-characters

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <fstream>

std::basic_filebuf<char, std::char_traits<wchar_t> > f;
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@fstream:* {{only virtual member functions can be marked 'override'}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@*:* 9 {{only virtual member functions can be marked 'override'}}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

// UNSUPPORTED: no-wide-characters

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <fstream>

std::basic_fstream<char, std::char_traits<wchar_t> > f;
// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}

// expected-error@*:* 11 {{only virtual member functions can be marked 'override'}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

// UNSUPPORTED: no-wide-characters

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <istream>
#include <string>

struct test_istream
: public std::basic_istream<char, std::char_traits<wchar_t> > {};

// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@istream:* {{only virtual member functions can be marked 'override'}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@*:* {{only virtual member functions can be marked 'override'}}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

// UNSUPPORTED: no-wide-characters

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <ostream>
#include <string>

struct test_ostream
: public std::basic_ostream<char, std::char_traits<wchar_t> > {};

// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@*:* {{only virtual member functions can be marked 'override'}}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@

// UNSUPPORTED: no-wide-characters

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <sstream>

std::basic_stringbuf<char, std::char_traits<wchar_t> > sb;
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@string:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}

// expected-error@sstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@sstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@sstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@sstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@sstream:* {{only virtual member functions can be marked 'override'}}
// expected-error@*:* 5 {{only virtual member functions can be marked 'override'}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// void fill(const T& u);

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <array>
#include <cassert>

Expand All @@ -20,7 +18,7 @@ int main(int, char**) {
typedef double T;
typedef std::array<const T, 0> C;
C c = {};
// expected-error-re@array:* {{static assertion failed{{.*}}cannot fill zero-sized array of type 'const T'}}
// expected-error-re@*:* {{static assertion failed{{.*}}cannot fill zero-sized array of type 'const T'}}
c.fill(5.5); // expected-note {{requested here}}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// void swap(array& a);

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <array>
#include <cassert>

Expand All @@ -21,7 +19,7 @@ int main(int, char**) {
typedef std::array<const T, 0> C;
C c = {};
C c2 = {};
// expected-error-re@array:* {{static assertion failed{{.*}}cannot swap zero-sized array of type 'const T'}}
// expected-error-re@*:* {{static assertion failed{{.*}}cannot swap zero-sized array of type 'const T'}}
c.swap(c2); // expected-note {{requested here}}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

// template <size_t I, class T, size_t N> T& get(array<T, N>& a);

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify.
// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-array-bounds

Expand All @@ -23,5 +21,5 @@ void f() {
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
std::get<3>(c) = 5.5; // expected-note {{requested here}}
// expected-error-re@array:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::get<> (std::array)}}
// expected-error-re@*:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::get<> (std::array)}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

// tuple_element<I, array<T, N> >::type

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <array>
#include <cassert>

typedef double T;
typedef std::array<T, 3> C;
std::tuple_element<3, C> foo; // expected-note {{requested here}}
// expected-error-re@array:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::tuple_element<> (std::array)}}
// expected-error-re@*:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::tuple_element<> (std::array)}}
8 changes: 3 additions & 5 deletions libcxx/test/std/strings/basic.string/char.bad.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// <string>
// ... manipulating sequences of any non-array trivial standard-layout types.

// XFAIL: FROZEN-CXX03-HEADERS-FIXME

#include <string>
#include "test_traits.h"

Expand All @@ -35,20 +33,20 @@ void f() {
typedef char C[3];
static_assert(std::is_array<C>::value, "");
std::basic_string<C, test_traits<C> > s;
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must not be an array}}
// expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must not be an array}}
}

{
// not trivial
static_assert(!std::is_trivial<NotTrivial>::value, "");
std::basic_string<NotTrivial, test_traits<NotTrivial> > s;
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be trivial}}
// expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be trivial}}
}

{
// not standard layout
static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s;
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be standard-layout}}
// expected-error-re@*:* {{static assertion failed{{.*}}Character type of basic_string must be standard-layout}}
}
}