1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -verify -std=c++11 %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc template<typename T> struct complex {
4*f4a2713aSLionel Sambuc complex(T = T(), T = T());
5*f4a2713aSLionel Sambuc void operator+=(complex);
6*f4a2713aSLionel Sambuc T a, b;
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc
std_example()9*f4a2713aSLionel Sambuc void std_example() {
10*f4a2713aSLionel Sambuc complex<double> z;
11*f4a2713aSLionel Sambuc z = { 1, 2 };
12*f4a2713aSLionel Sambuc z += { 1, 2 };
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc int a, b;
15*f4a2713aSLionel Sambuc a = b = { 1 };
16*f4a2713aSLionel Sambuc a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
17*f4a2713aSLionel Sambuc a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}}
18*f4a2713aSLionel Sambuc a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \
19*f4a2713aSLionel Sambuc expected-error {{initializer list cannot be used on the right hand side of operator '*'}}
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc struct S {
SS23*f4a2713aSLionel Sambuc constexpr S(int a, int b) : a(a), b(b) {}
24*f4a2713aSLionel Sambuc int a, b;
25*f4a2713aSLionel Sambuc };
26*f4a2713aSLionel Sambuc struct T {
operator =T27*f4a2713aSLionel Sambuc constexpr int operator=(S s) const { return s.a; }
operator +=T28*f4a2713aSLionel Sambuc constexpr int operator+=(S s) const { return s.b; }
29*f4a2713aSLionel Sambuc };
30*f4a2713aSLionel Sambuc static_assert((T() = {4, 9}) == 4, "");
31*f4a2713aSLionel Sambuc static_assert((T() += {4, 9}) == 9, "");
32*f4a2713aSLionel Sambuc
33*f4a2713aSLionel Sambuc int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
34*f4a2713aSLionel Sambuc int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}}
35