1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 // Test that only the default constructor is constexpr in C++11
19 constexpr explicit ExplicitT(int x
) : value(x
) {}
20 constexpr explicit ExplicitT(ExplicitT
const& o
) : value(o
.value
) {}
25 constexpr ImplicitT(int x
) : value(x
) {}
26 constexpr ImplicitT(ImplicitT
const& o
) : value(o
.value
) {}
32 using P
= std::pair
<int, int>;
34 constexpr P default_p
{};
35 constexpr P
copy_p(default_p
);
36 constexpr P
const_U_V(x
, x
); // expected-error {{must be initialized by a constant expression}}
37 constexpr P
U_V(42, 101); // expected-error {{must be initialized by a constant expression}}
40 using P
= std::pair
<ExplicitT
, ExplicitT
>;
41 constexpr std::pair
<int, int> other
;
42 constexpr ExplicitT
e(99);
43 constexpr P
const_U_V(e
, e
); // expected-error {{must be initialized by a constant expression}}
44 constexpr P
U_V(42, 101); // expected-error {{must be initialized by a constant expression}}
45 constexpr P
pair_U_V(other
); // expected-error {{must be initialized by a constant expression}}
48 using P
= std::pair
<ImplicitT
, ImplicitT
>;
49 constexpr std::pair
<int, int> other
;
50 constexpr ImplicitT i
= 99;
51 constexpr P const_U_V
= {i
, i
}; // expected-error {{must be initialized by a constant expression}}
52 constexpr P U_V
= {42, 101}; // expected-error {{must be initialized by a constant expression}}
53 constexpr P pair_U_V
= other
; // expected-error {{must be initialized by a constant expression}}