Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / expr / expr.ass / p9-cxx11.cpp
blobecc6d2c3d5bfafc408094cc0d35d1936d708c1fd
1 // RUN: %clang_cc1 -verify -std=c++11 %s
3 template<typename T> struct complex {
4 complex(T = T(), T = T());
5 void operator+=(complex);
6 T a, b;
7 };
9 void std_example() {
10 complex<double> z;
11 z = { 1, 2 };
12 z += { 1, 2 };
14 int a, b;
15 a = b = { 1 };
16 a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
17 a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}}
18 a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \
19 expected-error {{initializer list cannot be used on the right hand side of operator '*'}}
22 struct S {
23 constexpr S(int a, int b) : a(a), b(b) {}
24 int a, b;
26 struct T {
27 constexpr int operator=(S s) const { return s.a; }
28 constexpr int operator+=(S s) const { return s.b; }
30 static_assert((T() = {4, 9}) == 4, "");
31 static_assert((T() += {4, 9}) == 9, "");
33 int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
34 int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}}