Sebastian Redl | 10f04a6 | 2011-12-22 14:44:04 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s |
| 2 | |
| 3 | namespace objects { |
| 4 | |
| 5 | struct X1 { X1(int); }; |
| 6 | struct X2 { explicit X2(int); }; // expected-note 2 {{candidate constructor}} |
| 7 | |
| 8 | template <int N> |
| 9 | struct A { |
| 10 | A() { static_assert(N == 0, ""); } |
| 11 | A(int, double) { static_assert(N == 1, ""); } |
| 12 | }; |
| 13 | |
| 14 | template <int N> |
| 15 | struct E { |
| 16 | E(int, int) { static_assert(N == 0, ""); } |
| 17 | E(X1, int) { static_assert(N == 1, ""); } |
| 18 | }; |
| 19 | |
| 20 | void overload_resolution() { |
| 21 | { A<0> a{}; } |
| 22 | { A<0> a = {}; } |
| 23 | { A<1> a{1, 1.0}; } |
| 24 | { A<1> a = {1, 1.0}; } |
| 25 | |
| 26 | { E<0> e{1, 2}; } |
| 27 | } |
| 28 | |
| 29 | void explicit_implicit() { |
| 30 | { X1 x{0}; } |
| 31 | { X1 x = {0}; } |
| 32 | { X2 x{0}; } |
| 33 | { X2 x = {0}; } // expected-error {{no matching constructor}} |
| 34 | } |
| 35 | |
| 36 | struct C { |
| 37 | C(); |
| 38 | C(int, double); |
| 39 | C(int, int); |
| 40 | |
| 41 | int operator[](C); |
| 42 | }; |
| 43 | |
| 44 | C function_call() { |
| 45 | void takes_C(C); |
| 46 | takes_C({1, 1.0}); |
| 47 | |
| 48 | //C c; |
| 49 | //c[{1, 1.0}]; needs overloading |
| 50 | |
| 51 | return {1, 1.0}; |
| 52 | } |
| 53 | |
| 54 | void inline_init() { |
Sebastian Redl | 62f13c9 | 2011-12-22 18:58:29 +0000 | [diff] [blame^] | 55 | (void) C{1, 1.0}; |
Sebastian Redl | 10f04a6 | 2011-12-22 14:44:04 +0000 | [diff] [blame] | 56 | (void) new C{1, 1.0}; |
| 57 | } |
| 58 | |
| 59 | struct B { |
| 60 | B(C, int, C); |
| 61 | }; |
| 62 | |
| 63 | void nested_init() { |
| 64 | //B b{{1, 1.0}, 2, {3, 4}}; needs overloading |
| 65 | } |
| 66 | } |