summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-references.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-05-31 02:56:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-05-31 02:56:17 +0000
commit72752e88efa9179417626b9030425a71f952ba54 (patch)
tree232f1f6f7749db3a74e3985c0b09d31f630b7739 /clang/test/SemaCXX/cxx0x-initializer-references.cpp
parent7b4f8a4181c032330d75780b97dee0d3b4d3dc5f (diff)
downloadbcm5719-llvm-72752e88efa9179417626b9030425a71f952ba54.tar.gz
bcm5719-llvm-72752e88efa9179417626b9030425a71f952ba54.zip
Fix handling of braced-init-list as reference initializer within aggregate
initialization. Previously we would incorrectly require an extra set of braces around such initializers. llvm-svn: 182983
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-references.cpp')
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-references.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-references.cpp b/clang/test/SemaCXX/cxx0x-initializer-references.cpp
index 283c32ac2ef..48236fdf76f 100644
--- a/clang/test/SemaCXX/cxx0x-initializer-references.cpp
+++ b/clang/test/SemaCXX/cxx0x-initializer-references.cpp
@@ -97,3 +97,24 @@ namespace b7891773 {
int g(const ptr &);
int k = g({ f<int> });
}
+
+namespace inner_init {
+ struct A { int n; };
+ struct B { A &&r; };
+ B b1 { 0 }; // expected-error {{reference to type 'inner_init::A' could not bind to an rvalue of type 'int'}}
+ B b2 { { 0 } };
+ B b3 { { { 0 } } }; // expected-warning {{braces around scalar init}}
+
+ struct C { C(int); };
+ struct D { C &&r; };
+ D d1 { 0 }; // ok, 0 implicitly converts to C
+ D d2 { { 0 } }; // ok, { 0 } calls C(0)
+ D d3 { { { 0 } } }; // ok, { { 0 } } calls C({ 0 })
+ D d4 { { { { 0 } } } }; // expected-warning {{braces around scalar init}}
+
+ struct E { explicit E(int); }; // expected-note 2{{here}}
+ struct F { E &&r; };
+ F f1 { 0 }; // expected-error {{could not bind to an rvalue of type 'int'}}
+ F f2 { { 0 } }; // expected-error {{chosen constructor is explicit}}
+ F f3 { { { 0 } } }; // expected-error {{chosen constructor is explicit}}
+}
OpenPOWER on IntegriCloud