mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00

This patch removes some vendor-specific availability XFAILs from the test suite. In the future, when a new feature is introduced in the dylib, an availability macro should be created and a matching lit feature should be created. That way, the test suite can XFAIL whenever the implementation lacks the necessary feature instead of being cluttered by vendor-specific annotations. Right now, those vendor-specific annotations are still somewhat cluttering the test suite by being in `config.py`, but at least they are localized. In the future, we could design a way to define those less intrusively or even automatically based on the availability macros that already exist in <__config>. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@353201 91177308-0d34-0410-b5e6-96231b3b80d8
69 lines
1.6 KiB
C++
69 lines
1.6 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
|
|
|
// XFAIL: dylib-has-no-bad_optional_access
|
|
|
|
// <optional>
|
|
|
|
// constexpr const T& optional<T>::value() const &&;
|
|
|
|
#include <optional>
|
|
#include <type_traits>
|
|
#include <cassert>
|
|
|
|
#include "test_macros.h"
|
|
|
|
using std::optional;
|
|
using std::in_place_t;
|
|
using std::in_place;
|
|
using std::bad_optional_access;
|
|
|
|
struct X
|
|
{
|
|
X() = default;
|
|
X(const X&) = delete;
|
|
constexpr int test() const & {return 3;}
|
|
int test() & {return 4;}
|
|
constexpr int test() const && {return 5;}
|
|
int test() && {return 6;}
|
|
};
|
|
|
|
int main(int, char**)
|
|
{
|
|
{
|
|
const optional<X> opt; ((void)opt);
|
|
ASSERT_NOT_NOEXCEPT(std::move(opt).value());
|
|
ASSERT_SAME_TYPE(decltype(std::move(opt).value()), X const&&);
|
|
}
|
|
{
|
|
constexpr optional<X> opt(in_place);
|
|
static_assert(std::move(opt).value().test() == 5, "");
|
|
}
|
|
{
|
|
const optional<X> opt(in_place);
|
|
assert(std::move(opt).value().test() == 5);
|
|
}
|
|
#ifndef TEST_HAS_NO_EXCEPTIONS
|
|
{
|
|
const optional<X> opt;
|
|
try
|
|
{
|
|
(void)std::move(opt).value();
|
|
assert(false);
|
|
}
|
|
catch (const bad_optional_access&)
|
|
{
|
|
}
|
|
}
|
|
#endif
|
|
|
|
return 0;
|
|
}
|