mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[libc++] Implement P0551
Make sure we satisfy the requirements added by P0551, and add tests to enforce that.
This commit is contained in:
parent
fb558ccae7
commit
2d3b8cc83f
@ -843,7 +843,7 @@ basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* _
|
||||
ios_base::set_rdbuf(__sb);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
boolalpha(ios_base& __str)
|
||||
{
|
||||
@ -851,7 +851,7 @@ boolalpha(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
noboolalpha(ios_base& __str)
|
||||
{
|
||||
@ -859,7 +859,7 @@ noboolalpha(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
showbase(ios_base& __str)
|
||||
{
|
||||
@ -867,7 +867,7 @@ showbase(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
noshowbase(ios_base& __str)
|
||||
{
|
||||
@ -875,7 +875,7 @@ noshowbase(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
showpoint(ios_base& __str)
|
||||
{
|
||||
@ -883,7 +883,7 @@ showpoint(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
noshowpoint(ios_base& __str)
|
||||
{
|
||||
@ -891,7 +891,7 @@ noshowpoint(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
showpos(ios_base& __str)
|
||||
{
|
||||
@ -899,7 +899,7 @@ showpos(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
noshowpos(ios_base& __str)
|
||||
{
|
||||
@ -907,7 +907,7 @@ noshowpos(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
skipws(ios_base& __str)
|
||||
{
|
||||
@ -915,7 +915,7 @@ skipws(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
noskipws(ios_base& __str)
|
||||
{
|
||||
@ -923,7 +923,7 @@ noskipws(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
uppercase(ios_base& __str)
|
||||
{
|
||||
@ -931,7 +931,7 @@ uppercase(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
nouppercase(ios_base& __str)
|
||||
{
|
||||
@ -939,7 +939,7 @@ nouppercase(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
unitbuf(ios_base& __str)
|
||||
{
|
||||
@ -947,7 +947,7 @@ unitbuf(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
nounitbuf(ios_base& __str)
|
||||
{
|
||||
@ -955,7 +955,7 @@ nounitbuf(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
internal(ios_base& __str)
|
||||
{
|
||||
@ -963,7 +963,7 @@ internal(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
left(ios_base& __str)
|
||||
{
|
||||
@ -971,7 +971,7 @@ left(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
right(ios_base& __str)
|
||||
{
|
||||
@ -979,7 +979,7 @@ right(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
dec(ios_base& __str)
|
||||
{
|
||||
@ -987,7 +987,7 @@ dec(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
hex(ios_base& __str)
|
||||
{
|
||||
@ -995,7 +995,7 @@ hex(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
oct(ios_base& __str)
|
||||
{
|
||||
@ -1003,7 +1003,7 @@ oct(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
fixed(ios_base& __str)
|
||||
{
|
||||
@ -1011,7 +1011,7 @@ fixed(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
scientific(ios_base& __str)
|
||||
{
|
||||
@ -1019,7 +1019,7 @@ scientific(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
hexfloat(ios_base& __str)
|
||||
{
|
||||
@ -1027,7 +1027,7 @@ hexfloat(ios_base& __str)
|
||||
return __str;
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
ios_base&
|
||||
defaultfloat(ios_base& __str)
|
||||
{
|
||||
|
@ -999,7 +999,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
endl(basic_ostream<_CharT, _Traits>& __os)
|
||||
{
|
||||
@ -1009,7 +1009,7 @@ endl(basic_ostream<_CharT, _Traits>& __os)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
ends(basic_ostream<_CharT, _Traits>& __os)
|
||||
{
|
||||
@ -1018,7 +1018,7 @@ ends(basic_ostream<_CharT, _Traits>& __os)
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
flush(basic_ostream<_CharT, _Traits>& __os)
|
||||
{
|
||||
|
185
libcxx/test/std/namespace/addressable_functions.sh.cpp
Normal file
185
libcxx/test/std/namespace/addressable_functions.sh.cpp
Normal file
@ -0,0 +1,185 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Make sure functions specified as being 'addressable' (their address can be
|
||||
// taken in a well-defined manner) are indeed addressable. This notion was
|
||||
// added by http://wg21.link/p0551. While it was technically only introduced
|
||||
// in C++20, we test it in all standard modes because it's basic QOI to provide
|
||||
// a consistent behavior for that across standard modes.
|
||||
|
||||
// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %t.tu1.o -DTU1
|
||||
// RUN: %{cxx} %{flags} %{compile_flags} -c %s -o %t.tu2.o -DTU2
|
||||
// RUN: %{cxx} %{flags} %{link_flags} %t.tu1.o %t.tu2.o -o %t.exe
|
||||
// RUN: %{exec} %t.exe
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
|
||||
typedef std::ios_base& (FormatFlagFunction)(std::ios_base&);
|
||||
typedef std::basic_ostream<char>& (OstreamManipFunction)(std::basic_ostream<char>&);
|
||||
typedef std::basic_ostream<wchar_t>& (WOstreamManipFunction)(std::basic_ostream<wchar_t>&);
|
||||
typedef std::basic_istream<char>& (IstreamManipFunction)(std::basic_istream<char>&);
|
||||
typedef std::basic_istream<wchar_t>& (WIstreamManipFunction)(std::basic_istream<wchar_t>&);
|
||||
|
||||
extern FormatFlagFunction* get_formatflag_tu1(std::string);
|
||||
extern FormatFlagFunction* get_formatflag_tu2(std::string);
|
||||
|
||||
extern OstreamManipFunction* get_ostreammanip_tu1(std::string);
|
||||
extern OstreamManipFunction* get_ostreammanip_tu2(std::string);
|
||||
extern WOstreamManipFunction* get_wostreammanip_tu1(std::string);
|
||||
extern WOstreamManipFunction* get_wostreammanip_tu2(std::string);
|
||||
|
||||
extern IstreamManipFunction* get_istreammanip_tu1(std::string);
|
||||
extern IstreamManipFunction* get_istreammanip_tu2(std::string);
|
||||
extern WIstreamManipFunction* get_wistreammanip_tu1(std::string);
|
||||
extern WIstreamManipFunction* get_wistreammanip_tu2(std::string);
|
||||
|
||||
#ifdef TU1
|
||||
FormatFlagFunction* get_formatflag_tu1(std::string func)
|
||||
#else
|
||||
FormatFlagFunction* get_formatflag_tu2(std::string func)
|
||||
#endif
|
||||
{
|
||||
std::map<std::string, FormatFlagFunction*> all_funcs;
|
||||
|
||||
// [fmtflags.manip]
|
||||
all_funcs.insert(std::make_pair("boolalpha", &std::boolalpha));
|
||||
all_funcs.insert(std::make_pair("noboolalpha", &std::noboolalpha));
|
||||
all_funcs.insert(std::make_pair("showbase", &std::showbase));
|
||||
all_funcs.insert(std::make_pair("noshowbase", &std::noshowbase));
|
||||
all_funcs.insert(std::make_pair("showpoint", &std::showpoint));
|
||||
all_funcs.insert(std::make_pair("noshowpoint", &std::noshowpoint));
|
||||
all_funcs.insert(std::make_pair("showpos", &std::showpos));
|
||||
all_funcs.insert(std::make_pair("noshowpos", &std::noshowpos));
|
||||
all_funcs.insert(std::make_pair("skipws", &std::skipws));
|
||||
all_funcs.insert(std::make_pair("noskipws", &std::noskipws));
|
||||
all_funcs.insert(std::make_pair("uppercase", &std::uppercase));
|
||||
all_funcs.insert(std::make_pair("nouppercase", &std::nouppercase));
|
||||
all_funcs.insert(std::make_pair("unitbuf", &std::unitbuf));
|
||||
all_funcs.insert(std::make_pair("nounitbuf", &std::nounitbuf));
|
||||
|
||||
// [adjustfield.manip]
|
||||
all_funcs.insert(std::make_pair("internal", &std::internal));
|
||||
all_funcs.insert(std::make_pair("left", &std::left));
|
||||
all_funcs.insert(std::make_pair("right", &std::right));
|
||||
|
||||
// [basefield.manip]
|
||||
all_funcs.insert(std::make_pair("dec", &std::dec));
|
||||
all_funcs.insert(std::make_pair("hex", &std::hex));
|
||||
all_funcs.insert(std::make_pair("oct", &std::oct));
|
||||
|
||||
// [floatfield.manip]
|
||||
all_funcs.insert(std::make_pair("fixed", &std::fixed));
|
||||
all_funcs.insert(std::make_pair("scientific", &std::scientific));
|
||||
all_funcs.insert(std::make_pair("hexfloat", &std::hexfloat));
|
||||
all_funcs.insert(std::make_pair("defaultfloat", &std::defaultfloat));
|
||||
|
||||
return all_funcs.at(func);
|
||||
}
|
||||
|
||||
// [ostream.manip] (char)
|
||||
#ifdef TU1
|
||||
OstreamManipFunction* get_ostreammanip_tu1(std::string func)
|
||||
#else
|
||||
OstreamManipFunction* get_ostreammanip_tu2(std::string func)
|
||||
#endif
|
||||
{
|
||||
std::map<std::string, OstreamManipFunction*> all_funcs;
|
||||
typedef std::char_traits<char> Traits;
|
||||
all_funcs.insert(std::make_pair("endl", &std::endl<char, Traits>));
|
||||
all_funcs.insert(std::make_pair("ends", &std::ends<char, Traits>));
|
||||
all_funcs.insert(std::make_pair("flush", &std::flush<char, Traits>));
|
||||
return all_funcs.at(func);
|
||||
}
|
||||
|
||||
// [ostream.manip] (wchar_t)
|
||||
#ifdef TU1
|
||||
WOstreamManipFunction* get_wostreammanip_tu1(std::string func)
|
||||
#else
|
||||
WOstreamManipFunction* get_wostreammanip_tu2(std::string func)
|
||||
#endif
|
||||
{
|
||||
std::map<std::string, WOstreamManipFunction*> all_funcs;
|
||||
typedef std::char_traits<wchar_t> Traits;
|
||||
all_funcs.insert(std::make_pair("endl", &std::endl<wchar_t, Traits>));
|
||||
all_funcs.insert(std::make_pair("ends", &std::ends<wchar_t, Traits>));
|
||||
all_funcs.insert(std::make_pair("flush", &std::flush<wchar_t, Traits>));
|
||||
return all_funcs.at(func);
|
||||
}
|
||||
|
||||
// [istream.manip] (char)
|
||||
#ifdef TU1
|
||||
IstreamManipFunction* get_istreammanip_tu1(std::string func)
|
||||
#else
|
||||
IstreamManipFunction* get_istreammanip_tu2(std::string func)
|
||||
#endif
|
||||
{
|
||||
std::map<std::string, IstreamManipFunction*> all_funcs;
|
||||
typedef std::char_traits<char> Traits;
|
||||
all_funcs.insert(std::make_pair("ws", &std::ws<char, Traits>));
|
||||
return all_funcs.at(func);
|
||||
}
|
||||
|
||||
// [istream.manip] (wchar_t)
|
||||
#ifdef TU1
|
||||
WIstreamManipFunction* get_wistreammanip_tu1(std::string func)
|
||||
#else
|
||||
WIstreamManipFunction* get_wistreammanip_tu2(std::string func)
|
||||
#endif
|
||||
{
|
||||
std::map<std::string, WIstreamManipFunction*> all_funcs;
|
||||
typedef std::char_traits<wchar_t> Traits;
|
||||
all_funcs.insert(std::make_pair("ws", &std::ws<wchar_t, Traits>));
|
||||
return all_funcs.at(func);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TU2
|
||||
int main() {
|
||||
assert(get_formatflag_tu1("boolalpha") == get_formatflag_tu2("boolalpha"));
|
||||
assert(get_formatflag_tu1("noboolalpha") == get_formatflag_tu2("noboolalpha"));
|
||||
assert(get_formatflag_tu1("showbase") == get_formatflag_tu2("showbase"));
|
||||
assert(get_formatflag_tu1("noshowbase") == get_formatflag_tu2("noshowbase"));
|
||||
assert(get_formatflag_tu1("showpoint") == get_formatflag_tu2("showpoint"));
|
||||
assert(get_formatflag_tu1("noshowpoint") == get_formatflag_tu2("noshowpoint"));
|
||||
assert(get_formatflag_tu1("showpos") == get_formatflag_tu2("showpos"));
|
||||
assert(get_formatflag_tu1("noshowpos") == get_formatflag_tu2("noshowpos"));
|
||||
assert(get_formatflag_tu1("skipws") == get_formatflag_tu2("skipws"));
|
||||
assert(get_formatflag_tu1("noskipws") == get_formatflag_tu2("noskipws"));
|
||||
assert(get_formatflag_tu1("uppercase") == get_formatflag_tu2("uppercase"));
|
||||
assert(get_formatflag_tu1("nouppercase") == get_formatflag_tu2("nouppercase"));
|
||||
assert(get_formatflag_tu1("unitbuf") == get_formatflag_tu2("unitbuf"));
|
||||
assert(get_formatflag_tu1("nounitbuf") == get_formatflag_tu2("nounitbuf"));
|
||||
assert(get_formatflag_tu1("internal") == get_formatflag_tu2("internal"));
|
||||
assert(get_formatflag_tu1("left") == get_formatflag_tu2("left"));
|
||||
assert(get_formatflag_tu1("right") == get_formatflag_tu2("right"));
|
||||
assert(get_formatflag_tu1("dec") == get_formatflag_tu2("dec"));
|
||||
assert(get_formatflag_tu1("hex") == get_formatflag_tu2("hex"));
|
||||
assert(get_formatflag_tu1("oct") == get_formatflag_tu2("oct"));
|
||||
assert(get_formatflag_tu1("fixed") == get_formatflag_tu2("fixed"));
|
||||
assert(get_formatflag_tu1("scientific") == get_formatflag_tu2("scientific"));
|
||||
assert(get_formatflag_tu1("hexfloat") == get_formatflag_tu2("hexfloat"));
|
||||
assert(get_formatflag_tu1("defaultfloat") == get_formatflag_tu2("defaultfloat"));
|
||||
|
||||
assert(get_ostreammanip_tu1("endl") == get_ostreammanip_tu2("endl"));
|
||||
assert(get_ostreammanip_tu1("ends") == get_ostreammanip_tu2("ends"));
|
||||
assert(get_ostreammanip_tu1("flush") == get_ostreammanip_tu2("flush"));
|
||||
|
||||
assert(get_wostreammanip_tu1("endl") == get_wostreammanip_tu2("endl"));
|
||||
assert(get_wostreammanip_tu1("ends") == get_wostreammanip_tu2("ends"));
|
||||
assert(get_wostreammanip_tu1("flush") == get_wostreammanip_tu2("flush"));
|
||||
|
||||
assert(get_istreammanip_tu1("ws") == get_istreammanip_tu2("ws"));
|
||||
|
||||
assert(get_wistreammanip_tu1("ws") == get_wistreammanip_tu2("ws"));
|
||||
}
|
||||
#endif
|
@ -73,7 +73,7 @@
|
||||
<tr><td><a href="https://wg21.link/P0777R1">P0777R1</a></td><td>LWG</td><td>Treating Unnecessary <tt>decay</tt></td><td>Albuquerque</td><td>Complete</td><td>7.0</td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0122R7">P0122R7</a></td><td>LWG</td><td><span></td><td>Jacksonville</td><td>Complete</td><td>7.0</td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0355R7">P0355R7</a></td><td>LWG</td><td>Extending chrono to Calendars and Time Zones</td><td>Jacksonville</td><td><i>In progress</i></td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0551R3">P0551R3</a></td><td>LWG</td><td>Thou Shalt Not Specialize <tt>std</tt> Function Templates!</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0551R3">P0551R3</a></td><td>LWG</td><td>Thou Shalt Not Specialize <tt>std</tt> Function Templates!</td><td>Jacksonville</td><td>Complete</td><td>11.0</td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0753R2">P0753R2</a></td><td>LWG</td><td>Manipulators for C++ Synchronized Buffered Ostream</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0754R2">P0754R2</a></td><td>LWG</td><td><version></td><td>Jacksonville</td><td>Complete</td><td>7.0</td></tr>
|
||||
<tr><td><a href="https://wg21.link/P0809R0">P0809R0</a></td><td>LWG</td><td>Comparing Unordered Containers</td><td>Jacksonville</td><td></td><td></td></tr>
|
||||
|
Loading…
Reference in New Issue
Block a user