annotate gcc/testsuite/g++.dg/ext/bases.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-options "-w" }
kono
parents:
diff changeset
2 // { dg-do run { target c++11 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 #include<typeinfo>
kono
parents:
diff changeset
5 #include<cassert>
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 // A simple typelist
kono
parents:
diff changeset
8 template<typename... _Elements> struct types {};
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 // Simple bases implementation
kono
parents:
diff changeset
11 template<typename T> struct b {
kono
parents:
diff changeset
12 typedef types<__bases(T)...> type;
kono
parents:
diff changeset
13 };
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 // Simple direct_bases implementation
kono
parents:
diff changeset
16 template<typename T> struct db {
kono
parents:
diff changeset
17 typedef types<__direct_bases(T)...> type;
kono
parents:
diff changeset
18 };
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 template <class,class> struct assert_same_type;
kono
parents:
diff changeset
21 template <class T> struct assert_same_type<T,T> {};
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 struct A {};
kono
parents:
diff changeset
24 struct C : virtual A {};
kono
parents:
diff changeset
25 struct D : public C {};
kono
parents:
diff changeset
26 struct B : D, virtual A {};
kono
parents:
diff changeset
27 struct E : C, virtual D, B {};
kono
parents:
diff changeset
28 struct F : A, B, E {};
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 int main() {
kono
parents:
diff changeset
31 assert_same_type<b<F>::type, types<A,C,D,A,C,D,B,C,C,D,B,E>>();
kono
parents:
diff changeset
32 assert_same_type<db<F>::type, types<A,B,E>>();
kono
parents:
diff changeset
33 assert_same_type<db<int>::type, types<>>();
kono
parents:
diff changeset
34 return 0;
kono
parents:
diff changeset
35 }