2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-06-30 06:33:26 +08:00
|
|
|
|
|
|
|
class S {
|
|
|
|
public:
|
|
|
|
S ();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D : S {
|
2010-03-31 00:19:37 +08:00
|
|
|
D() :
|
|
|
|
b1(0), // expected-note {{previous initialization is here}}
|
|
|
|
b2(1),
|
|
|
|
b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
|
|
|
|
S(), // expected-note {{previous initialization is here}}
|
|
|
|
S() // expected-error {{multiple initializations given for base 'S'}}
|
|
|
|
{}
|
2009-06-30 06:33:26 +08:00
|
|
|
int b1;
|
|
|
|
int b2;
|
|
|
|
};
|
|
|
|
|
2010-03-31 00:19:37 +08:00
|
|
|
struct A {
|
|
|
|
struct {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
A();
|
|
|
|
};
|
2009-06-30 06:33:26 +08:00
|
|
|
|
2010-03-31 00:19:37 +08:00
|
|
|
A::A() : a(10), b(20) { }
|
2010-04-02 13:42:15 +08:00
|
|
|
|
|
|
|
namespace Test1 {
|
|
|
|
template<typename T> struct A {};
|
|
|
|
template<typename T> struct B : A<T> {
|
|
|
|
|
|
|
|
B() : A<T>(), // expected-note {{previous initialization is here}}
|
|
|
|
A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Test2 {
|
|
|
|
template<typename T> struct A : T {
|
|
|
|
A() : T(), // expected-note {{previous initialization is here}}
|
|
|
|
T() { } // expected-error {{multiple initializations given for base 'T'}}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Test3 {
|
|
|
|
template<typename T> struct A {
|
|
|
|
T t;
|
|
|
|
|
|
|
|
A() : t(1), // expected-note {{previous initialization is here}}
|
|
|
|
t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
|
|
|
|
};
|
|
|
|
}
|