xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/inherit.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc class A { };
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc class B1 : A { };
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc class B2 : virtual A { };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc class B3 : virtual virtual A { }; // expected-error{{duplicate 'virtual' in base specifier}}
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc class C : public B1, private B2 { };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc class D;                // expected-note {{forward declaration of 'D'}}
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc class E : public D { }; // expected-error{{base class has incomplete type}}
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc typedef int I;
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc class F : public I { }; // expected-error{{base specifier must name a class}}
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc union U1 : public A { }; // expected-error{{unions cannot have base classes}}
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc union U2 {};
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc class G : public U2 { }; // expected-error{{unions cannot be base classes}}
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc typedef G G_copy;
28*f4a2713aSLionel Sambuc typedef G G_copy_2;
29*f4a2713aSLionel Sambuc typedef G_copy G_copy_3;
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc class H : G_copy, A, G_copy_2, // expected-error{{base class 'G_copy' (aka 'G') specified more than once as a direct base class}}
32*f4a2713aSLionel Sambuc           public G_copy_3 { }; // expected-error{{base class 'G_copy' (aka 'G') specified more than once as a direct base class}}
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc struct J { char c; int i[]; };
35*f4a2713aSLionel Sambuc struct K : J { }; // expected-error{{base class 'J' has a flexible array member}}
36