]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / language.support / support.dynamic / ptr.launder / launder.types.fail.cpp
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 // <new>
12
13 // template <class T> constexpr T* launder(T* p) noexcept;
14 // The program is ill-formed if T is a function type or cv void.
15
16 // UNSUPPORTED: c++98, c++03, c++11, c++14
17
18 #include <new>
19 #include <cassert>
20
21 #include "test_macros.h"
22
23 void foo() {}
24
25 int main ()
26 {
27     void *p = nullptr;
28     (void) std::launder((               void *) nullptr);
29     (void) std::launder((const          void *) nullptr);
30     (void) std::launder((      volatile void *) nullptr);
31     (void) std::launder((const volatile void *) nullptr);  // expected-error-re@new:* 4 {{static_assert failed{{.*}} "can't launder cv-void"}}
32     // expected-error@new:* 0-4 {{void pointer argument to '__builtin_launder' is not allowed}}
33
34     (void) std::launder(foo);                              // expected-error-re@new:* 1 {{static_assert failed{{.*}} "can't launder functions"}}
35     // expected-error@new:* 0-1 {{function pointer argument to '__builtin_launder' is not allowed}}
36 }