2012-01-24 14:03:59 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -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'}}
|
|
|
|
};
|
|
|
|
}
|
2010-04-10 17:28:51 +08:00
|
|
|
|
|
|
|
namespace test4 {
|
|
|
|
class A {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
union {
|
|
|
|
int d;
|
|
|
|
int e;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
A(char _) : a(0), b(0) {}
|
2011-11-17 14:01:57 +08:00
|
|
|
A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
|
|
|
|
A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
|
|
|
|
A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
|
2010-04-10 17:28:51 +08:00
|
|
|
};
|
|
|
|
}
|
2012-01-24 14:03:59 +08:00
|
|
|
|
|
|
|
namespace test5 {
|
|
|
|
struct Base {
|
|
|
|
Base(int);
|
|
|
|
};
|
|
|
|
struct A : Base {
|
|
|
|
A() : decltype(Base(1))(3) {
|
|
|
|
}
|
|
|
|
A(int) : Base(3), // expected-note {{previous initialization is here}}
|
|
|
|
decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(test5::Base(1))' (aka 'test5::Base')}}
|
|
|
|
decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}}
|
|
|
|
}
|
|
|
|
A(float) : decltype(A())(3) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|