diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-12-22 14:44:04 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-12-22 14:44:04 +0000 |
commit | ed2e53222f1a55875dd6cec8c7578fe4c808fd7a (patch) | |
tree | 0dca010e674e1bc06d23d564c88c49e9962a54ee /clang/test/SemaCXX/cxx0x-initializer-constructor.cpp | |
parent | f1fd6e394d08c5915974c3c872a8e1db37e29a6e (diff) | |
download | bcm5719-llvm-ed2e53222f1a55875dd6cec8c7578fe4c808fd7a.tar.gz bcm5719-llvm-ed2e53222f1a55875dd6cec8c7578fe4c808fd7a.zip |
List-initialization via constructor part 1. Still needs: pretty-printing, overloading, initializer_list.
llvm-svn: 147145
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-constructor.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-initializer-constructor.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp b/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp new file mode 100644 index 00000000000..7eff4c41aa9 --- /dev/null +++ b/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp @@ -0,0 +1,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 + } +} |