diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-11-27 16:50:07 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-11-27 16:50:07 +0000 |
commit | 13dc8f98f6108dca8aaa9721567ed5a2d9911e0f (patch) | |
tree | c574193fb93fa87e8b2d568d1bf5cda53baa4b8a /test/SemaCXX/cxx0x-initializer-references.cpp | |
parent | 1376ba9dddccc02e8c187bbfa4c66f2c0938b0c0 (diff) |
Reference initialization with initializer lists.
This supports single-element initializer lists for references according to DR1288, as well as creating temporaries and binding to them for other initializer lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145186 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx0x-initializer-references.cpp')
-rw-r--r-- | test/SemaCXX/cxx0x-initializer-references.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-initializer-references.cpp b/test/SemaCXX/cxx0x-initializer-references.cpp new file mode 100644 index 0000000000..5bc355f8e4 --- /dev/null +++ b/test/SemaCXX/cxx0x-initializer-references.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace reference { + struct A { + int i1, i2; + }; + + void single_init() { + const int &cri1a = {1}; + const int &cri1b{1}; + + int i = 1; + int &ri1a = {i}; + int &ri1b{i}; + + int &ri2 = {1}; // expected-error {{cannot bind to an initializer list temporary}} + + A a{1, 2}; + A &ra1a = {a}; + A &ra1b{a}; + } + + void reference_to_aggregate() { + const A &ra1{1, 2}; + A &ra2{1, 2}; // expected-error {{cannot bind to an initializer list temporary}} + + const int (&arrayRef)[] = {1, 2, 3}; + static_assert(sizeof(arrayRef) == 3 * sizeof(int), "bad array size"); + } + +} |