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