diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-26 23:49:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-26 23:49:01 +0000 |
commit | dbe01bb024ce9407954275a5e3c7e1a7113ca9fa (patch) | |
tree | aaac353f1df591ebd529bcb68687da41d08c6634 | |
parent | c56ab4358fc1bcf1fb755475088fed09b8cfaa1e (diff) |
Tests for r151508.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151509 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CXX/expr/expr.ass/p9-cxx11.cpp | 32 | ||||
-rw-r--r-- | test/SemaCXX/cxx98-compat.cpp | 2 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/CXX/expr/expr.ass/p9-cxx11.cpp b/test/CXX/expr/expr.ass/p9-cxx11.cpp new file mode 100644 index 0000000000..fcef97cde5 --- /dev/null +++ b/test/CXX/expr/expr.ass/p9-cxx11.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -verify -std=c++11 %s + +template<typename T> struct complex { + complex(T = T(), T = T()); + void operator+=(complex); + T a, b; +}; + +void std_example() { + complex<double> z; + z = { 1, 2 }; + z += { 1, 2 }; + + // FIXME: implement semantics of scalar init list assignment. + int a, b; + a = b = { 1 }; // unexpected-error {{incompatible type 'void'}} + a = { 1 } = b; // unexpected-error {{incompatible type 'void'}} +} + +struct S { + constexpr S(int a, int b) : a(a), b(b) {} + int a, b; +}; +struct T { + constexpr int operator=(S s) { return s.a; } + constexpr int operator+=(S s) { return s.b; } +}; +static_assert((T() = {4, 9}) == 4, ""); +static_assert((T() += {4, 9}) == 9, ""); + +int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{expected ';'}} +int k2 = T() = { 1, 2 } + 1; // expected-error {{expected ';'}} diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp index 12b95765e0..8c15f5adc1 100644 --- a/test/SemaCXX/cxx98-compat.cpp +++ b/test/SemaCXX/cxx98-compat.cpp @@ -45,6 +45,8 @@ int InitList() { (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} + S<int> s = {}; // ok, aggregate + s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} } |