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 | 5a41f68fe2adb7cbd7b4fdbb52c7bd496cd83116 (patch) | |
tree | 278aa60f0b14ef2a5028f3239b0abb7a6ada37ba /clang/test | |
parent | 34ca89afa880d3a3fd7f968c6c818ad4475665c2 (diff) | |
download | bcm5719-llvm-5a41f68fe2adb7cbd7b4fdbb52c7bd496cd83116.tar.gz bcm5719-llvm-5a41f68fe2adb7cbd7b4fdbb52c7bd496cd83116.zip |
Employ DirectList initialized entities to properly sort through some initialization edge cases.
llvm-svn: 150342
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-initializer-constructor.cpp | 29 | ||||
-rw-r--r-- | clang/test/SemaCXX/generalized-initializers.cpp | 23 |
2 files changed, 29 insertions, 23 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp b/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp index 4858d7af9d7..3e74ad777f9 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-constructor.cpp +++ b/clang/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}; + } } diff --git a/clang/test/SemaCXX/generalized-initializers.cpp b/clang/test/SemaCXX/generalized-initializers.cpp index e62ff365e98..1228d300d14 100644 --- a/clang/test/SemaCXX/generalized-initializers.cpp +++ b/clang/test/SemaCXX/generalized-initializers.cpp @@ -49,27 +49,4 @@ namespace litb { // invalid int const &b({0}); // expected-error {{}} - struct C { explicit C(int, int); C(int, long); }; - - // invalid - C c({1, 2}); // expected-error {{}} - - // valid (by copy constructor). - C d({1, 2L}); - - // valid - C e{1, 2}; - - struct B { - template<typename ...T> - B(std::initializer_list<int>, T ...); - }; - - // invalid (the first phase only considers init-list ctors) - // (for the second phase, no constructor is viable) - B f{1, 2, 3}; - - // valid (T deduced to <>). - B g({1, 2, 3}); - } |