diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-12-03 14:54:30 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-12-03 14:54:30 +0000 |
commit | df888642733dda0a24612f3cc4ce9e7a5ad7f581 (patch) | |
tree | ebde012266e324f9bbe7250abf3dfac8a619d87c /clang/test/SemaCXX/cxx0x-initializer-references.cpp | |
parent | 006e43bcc0836f442057154cecc64581af4cf54a (diff) | |
download | bcm5719-llvm-df888642733dda0a24612f3cc4ce9e7a5ad7f581.tar.gz bcm5719-llvm-df888642733dda0a24612f3cc4ce9e7a5ad7f581.zip |
Implement overload resolution for reference-typed parameters supplied with initializer lists.
llvm-svn: 145769
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-references.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-initializer-references.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-references.cpp b/clang/test/SemaCXX/cxx0x-initializer-references.cpp index 5bc355f8e49..f84f1be7d51 100644 --- a/clang/test/SemaCXX/cxx0x-initializer-references.cpp +++ b/clang/test/SemaCXX/cxx0x-initializer-references.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +struct one { char c; }; +struct two { char c[2]; }; + namespace reference { struct A { int i1, i2; @@ -28,4 +31,44 @@ namespace reference { static_assert(sizeof(arrayRef) == 3 * sizeof(int), "bad array size"); } + struct B { + int i1; + }; + + void call() { + void f(const int&); + f({1}); + + void g(int&); // expected-note {{passing argument}} + g({1}); // expected-error {{cannot bind to an initializer list temporary}} + int i = 0; + g({i}); + + void h(const B&); + h({1}); + + void a(B&); // expected-note {{passing argument}} + a({1}); // expected-error {{cannot bind to an initializer list temporary}} + B b{1}; + a({b}); + } + + void overloading() { + one f(const int&); + two f(const B&); + + // First is identity conversion, second is user-defined conversion. + static_assert(sizeof(f({1})) == sizeof(one), "bad overload resolution"); + + one g(int&); + two g(const B&); + + static_assert(sizeof(g({1})) == sizeof(two), "bad overload resolution"); + + one h(const int&); + two h(const A&); + + static_assert(sizeof(h({1, 2})) == sizeof(two), "bad overload resolution"); + } + } |