summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
blob: 7eff4c41aa9715dfe0fc825bd32120c11d8bf54c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s

namespace objects {

  struct X1 { X1(int); };
  struct X2 { explicit X2(int); }; // expected-note 2 {{candidate constructor}}

  template <int N>
  struct A {
    A() { static_assert(N == 0, ""); }
    A(int, double) { static_assert(N == 1, ""); }
  };

  template <int N>
  struct E {
    E(int, int) { static_assert(N == 0, ""); }
    E(X1, int) { static_assert(N == 1, ""); }
  };

  void overload_resolution() {
    { A<0> a{}; }
    { A<0> a = {}; }
    { A<1> a{1, 1.0}; }
    { A<1> a = {1, 1.0}; }

    { E<0> e{1, 2}; }
  }

  void explicit_implicit() {
    { X1 x{0}; }
    { X1 x = {0}; }
    { X2 x{0}; }
    { X2 x = {0}; } // expected-error {{no matching constructor}}
  }

  struct C {
    C();
    C(int, double);
    C(int, int);

    int operator[](C);
  };

  C function_call() {
    void takes_C(C);
    takes_C({1, 1.0});

    //C c;
    //c[{1, 1.0}]; needs overloading

    return {1, 1.0};
  }

  void inline_init() {
    //(void) C{1, 1.0}; FIXME: inline initialization
    (void) new C{1, 1.0};
  }

  struct B {
    B(C, int, C);
  };

  void nested_init() {
    //B b{{1, 1.0}, 2, {3, 4}}; needs overloading
  }
}
OpenPOWER on IntegriCloud