1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc class S {
4*f4a2713aSLionel Sambuc public:
5*f4a2713aSLionel Sambuc S ();
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc struct D : S {
DD9*f4a2713aSLionel Sambuc D() :
10*f4a2713aSLionel Sambuc b1(0), // expected-note {{previous initialization is here}}
11*f4a2713aSLionel Sambuc b2(1),
12*f4a2713aSLionel Sambuc b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
13*f4a2713aSLionel Sambuc S(), // expected-note {{previous initialization is here}}
14*f4a2713aSLionel Sambuc S() // expected-error {{multiple initializations given for base 'S'}}
15*f4a2713aSLionel Sambuc {}
16*f4a2713aSLionel Sambuc int b1;
17*f4a2713aSLionel Sambuc int b2;
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc struct A {
21*f4a2713aSLionel Sambuc struct {
22*f4a2713aSLionel Sambuc int a;
23*f4a2713aSLionel Sambuc int b;
24*f4a2713aSLionel Sambuc };
25*f4a2713aSLionel Sambuc A();
26*f4a2713aSLionel Sambuc };
27*f4a2713aSLionel Sambuc
A()28*f4a2713aSLionel Sambuc A::A() : a(10), b(20) { }
29*f4a2713aSLionel Sambuc
30*f4a2713aSLionel Sambuc namespace Test1 {
31*f4a2713aSLionel Sambuc template<typename T> struct A {};
32*f4a2713aSLionel Sambuc template<typename T> struct B : A<T> {
33*f4a2713aSLionel Sambuc
BTest1::B34*f4a2713aSLionel Sambuc B() : A<T>(), // expected-note {{previous initialization is here}}
35*f4a2713aSLionel Sambuc A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
36*f4a2713aSLionel Sambuc };
37*f4a2713aSLionel Sambuc }
38*f4a2713aSLionel Sambuc
39*f4a2713aSLionel Sambuc namespace Test2 {
40*f4a2713aSLionel Sambuc template<typename T> struct A : T {
ATest2::A41*f4a2713aSLionel Sambuc A() : T(), // expected-note {{previous initialization is here}}
42*f4a2713aSLionel Sambuc T() { } // expected-error {{multiple initializations given for base 'T'}}
43*f4a2713aSLionel Sambuc };
44*f4a2713aSLionel Sambuc }
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc namespace Test3 {
47*f4a2713aSLionel Sambuc template<typename T> struct A {
48*f4a2713aSLionel Sambuc T t;
49*f4a2713aSLionel Sambuc
ATest3::A50*f4a2713aSLionel Sambuc A() : t(1), // expected-note {{previous initialization is here}}
51*f4a2713aSLionel Sambuc t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
52*f4a2713aSLionel Sambuc };
53*f4a2713aSLionel Sambuc }
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc namespace test4 {
56*f4a2713aSLionel Sambuc class A {
57*f4a2713aSLionel Sambuc union {
58*f4a2713aSLionel Sambuc struct {
59*f4a2713aSLionel Sambuc int a;
60*f4a2713aSLionel Sambuc int b;
61*f4a2713aSLionel Sambuc };
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc int c;
64*f4a2713aSLionel Sambuc
65*f4a2713aSLionel Sambuc union {
66*f4a2713aSLionel Sambuc int d;
67*f4a2713aSLionel Sambuc int e;
68*f4a2713aSLionel Sambuc };
69*f4a2713aSLionel Sambuc };
70*f4a2713aSLionel Sambuc
A(char _)71*f4a2713aSLionel Sambuc A(char _) : a(0), b(0) {}
A(short _)72*f4a2713aSLionel Sambuc A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
A(int _)73*f4a2713aSLionel Sambuc A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
A(long _)74*f4a2713aSLionel Sambuc A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
75*f4a2713aSLionel Sambuc };
76*f4a2713aSLionel Sambuc }
77*f4a2713aSLionel Sambuc
78*f4a2713aSLionel Sambuc namespace test5 {
79*f4a2713aSLionel Sambuc struct Base {
80*f4a2713aSLionel Sambuc Base(int);
81*f4a2713aSLionel Sambuc };
82*f4a2713aSLionel Sambuc struct A : Base {
Atest5::A83*f4a2713aSLionel Sambuc A() : decltype(Base(1))(3) {
84*f4a2713aSLionel Sambuc }
Atest5::A85*f4a2713aSLionel Sambuc A(int) : Base(3), // expected-note {{previous initialization is here}}
86*f4a2713aSLionel Sambuc decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(test5::Base(1))' (aka 'test5::Base')}}
87*f4a2713aSLionel Sambuc decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}}
88*f4a2713aSLionel Sambuc }
Atest5::A89*f4a2713aSLionel Sambuc A(float) : decltype(A())(3) {
90*f4a2713aSLionel Sambuc }
91*f4a2713aSLionel Sambuc };
92*f4a2713aSLionel Sambuc }
93*f4a2713aSLionel Sambuc
94*f4a2713aSLionel Sambuc namespace rdar13185264 {
95*f4a2713aSLionel Sambuc class X {
X()96*f4a2713aSLionel Sambuc X() : a(), // expected-note{{previous initialization is here}}
97*f4a2713aSLionel Sambuc a() { } // expected-error{{multiple initializations given for non-static member 'a'}}
98*f4a2713aSLionel Sambuc union { void *a; };
99*f4a2713aSLionel Sambuc };
100*f4a2713aSLionel Sambuc }
101*f4a2713aSLionel Sambuc
102*f4a2713aSLionel Sambuc namespace PR16596 {
103*f4a2713aSLionel Sambuc class A { public: virtual ~A(); };
104*f4a2713aSLionel Sambuc typedef const A Foo;
105*f4a2713aSLionel Sambuc void Apply(Foo processor);
106*f4a2713aSLionel Sambuc struct Bar : public Foo {};
Fetch()107*f4a2713aSLionel Sambuc void Fetch() {
108*f4a2713aSLionel Sambuc Apply(Bar());
109*f4a2713aSLionel Sambuc }
110*f4a2713aSLionel Sambuc }
111