view gcc/testsuite/g++.dg/cpp1z/inh-ctor22.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Testcase from P0136
// { dg-do compile { target c++11 } }

struct B1 {
  template <class... Ts>
  B1(int, Ts...) { }
};

struct B2 {
  B2(double) { }
};

int get();

struct D1 : B1 {		// { dg-message "B1::B1" }
  using B1::B1;  // inherits B1(int, ...)
  int x;
  int y = get();
};

void test() {
  D1 d(2, 3, 4); // OK: B1 is initialized by calling B1(2, 3, 4),
  // then d.x is default-initialized (no initialization is performed),
  // then d.y is initialized by calling get()
  D1 e;          // { dg-error "" } D1 has a deleted default constructor
}

struct D2 : B2 {
  using B2::B2;			// { dg-message "B1::B1" }
  B1 b;
};

D2 f(1.0);       // { dg-error "" } B1 has no default constructor