1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
14 // Test that only the default constructor is constexpr in C++11
20 constexpr explicit ExplicitT(int x) : value(x) {}
21 constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
26 constexpr ImplicitT(int x) : value(x) {}
27 constexpr ImplicitT(ImplicitT const& o) : value(o.value) {}
34 using P = std::pair<int, int>;
36 constexpr P default_p{};
37 constexpr P copy_p(default_p);
38 constexpr P const_U_V(x, x); // expected-error {{must be initialized by a constant expression}}
39 constexpr P U_V(42, 101); // expected-error {{must be initialized by a constant expression}}
42 using P = std::pair<ExplicitT, ExplicitT>;
43 constexpr std::pair<int, int> other;
44 constexpr ExplicitT e(99);
45 constexpr P const_U_V(e, e); // expected-error {{must be initialized by a constant expression}}
46 constexpr P U_V(42, 101); // expected-error {{must be initialized by a constant expression}}
47 constexpr P pair_U_V(other); // expected-error {{must be initialized by a constant expression}}
50 using P = std::pair<ImplicitT, ImplicitT>;
51 constexpr std::pair<int, int> other;
52 constexpr ImplicitT i = 99;
53 constexpr P const_U_V = {i, i}; // expected-error {{must be initialized by a constant expression}}
54 constexpr P U_V = {42, 101}; // expected-error {{must be initialized by a constant expression}}
55 constexpr P pair_U_V = other; // expected-error {{must be initialized by a constant expression}}