p8.cpp revision cd37a0b6bbd8d46af116c72537e2129e4a077e5e
1// RUN: %clang_cc1 -std=c++11 -verify %s
2
3struct A {
4  constexpr A(const int&) : rval(false) {}
5  constexpr A(const int&&) : rval(true) {}
6  bool rval;
7};
8struct B : A {
9  using A::A;
10};
11
12constexpr int k = 0;
13constexpr A a0{0};
14constexpr A a1{k};
15constexpr B b0{0};
16// This performs static_cast<(const int&)&&>(k), so calls the A(const int&)
17// constructor.
18constexpr B b1{k};
19
20static_assert(a0.rval && !a1.rval && b0.rval && !b1.rval, "");
21
22struct C {
23  template<typename T> constexpr C(T t) : v(t) {}
24  int v;
25};
26struct D : C {
27  using C::C;
28};
29static_assert(D(123).v == 123, "");
30
31// FIXME: This diagnostic sucks.
32template<typename T> constexpr D::D(T t) : C(t) {} // expected-error {{definition of implicitly declared function}}
33