diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-12 16:37:24 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-12 16:37:24 +0000 |
commit | 168319c81b8f4e7addf36ad15ef24919faf23504 (patch) | |
tree | 4adce37b8c3d38972f20ef9e2f507dc19eea17cc /test/SemaCXX/cxx0x-initializer-constructor.cpp | |
parent | 8275fc0ba70b29a116e0892e582a8fb21124abf1 (diff) |
Employ DirectList initialized entities to properly sort through some initialization edge cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx0x-initializer-constructor.cpp')
-rw-r--r-- | test/SemaCXX/cxx0x-initializer-constructor.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-initializer-constructor.cpp b/test/SemaCXX/cxx0x-initializer-constructor.cpp index 4858d7af9d..3e74ad777f 100644 --- a/test/SemaCXX/cxx0x-initializer-constructor.cpp +++ b/test/SemaCXX/cxx0x-initializer-constructor.cpp @@ -146,4 +146,33 @@ namespace objects { static_assert(sizeof(ov2({1})) == sizeof(one), "bad overload"); // list -> int ranks as identity static_assert(sizeof(ov2({1, 2, 3})) == sizeof(two), "bad overload"); // list -> F only viable } + + struct G { // expected-note 2 {{not viable}} + // This is not an initializer-list constructor. + template<typename ...T> + G(std::initializer_list<int>, T ...); // expected-note {{not viable}} + }; + + struct H { // expected-note 2 {{not viable}} + explicit H(int, int); // expected-note {{not viable}} + H(int, void*); // expected-note {{not viable}} + }; + + void edge_cases() { + // invalid (the first phase only considers init-list ctors) + // (for the second phase, no constructor is viable) + G g1{1, 2, 3}; // expected-error {{no matching constructor}} + + // valid (T deduced to <>). + G g2({1, 2, 3}); + + // invalid + H h1({1, 2}); // expected-error {{no matching constructor}} + + // valid (by copy constructor). + H h2({1, nullptr}); + + // valid + H h3{1, 2}; + } } |