Clang Project

clang_source_code/test/SemaCXX/cxx2a-initializer-aggregates.cpp
1// RUN: %clang_cc1 -std=c++2a %s -verify
2
3namespace class_with_ctor {
4  struct A { // expected-note 6{{candidate}}
5    A() = default; // expected-note 3{{candidate}}
6    int x;
7    int y;
8  };
9  A a = {1, 2}; // expected-error {{no matching constructor}}
10
11  struct B {
12    int x;
13    int y;
14  };
15  B b1 = B(); // trigger declaration of implicit ctors
16  B b2 = {1, 2}; // ok
17
18  struct C : A {
19    A a;
20  };
21  C c1 = {{}, {}}; // ok, call default ctor twice
22  C c2 = {{1, 2}, {3, 4}}; // expected-error 2{{no matching constructor}}
23}
24