blob: d0c978a80d15d52f4c9cfa58d5b0f346a2f197a3 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor7ad83902008-11-05 04:29:56 +00002class A {
3 int m;
4};
5
6class B : public A {
7public:
8 B() : A(), m(1), n(3.14) { }
9
10private:
11 int m;
12 float n;
13};
14
15
16class C : public virtual B {
17public:
18 C() : B() { }
19};
20
21class D : public C {
22public:
23 D() : B(), C() { }
24};
25
26class E : public D, public B {
27public:
28 E() : B(), D() { } // expected-error{{base class initializer 'B' names both a direct base class and an inherited virtual base class}}
29};
30
31
32typedef int INT;
33
34class F : public B {
35public:
36 int B;
37
38 F() : B(17),
39 m(17), // expected-error{{member initializer 'm' does not name a non-static data member or base class}}
Chris Lattnerd0344a42009-02-19 23:45:49 +000040 INT(17) // expected-error{{constructor initializer 'INT' (aka 'int') does not name a class}}
Douglas Gregor7ad83902008-11-05 04:29:56 +000041 {
42 }
43};
Douglas Gregor3f08d182008-11-10 16:59:40 +000044
45class G : A {
46 G() : A(10); // expected-error{{expected '{'}}
47};
Anders Carlssona7b35212009-03-25 02:58:17 +000048
49void f() : a(242) { } // expected-error{{only constructors take base initializers}}
50
51class H : A {
52 H();
53};
54
55H::H() : A(10) { }
56