Debian Codegraph @

gcc/testsuite/g++.dg/lookup/using39.C

raw
1 // { dg-do run }
2
3 template <class T>
4 struct A
5 {
6 int f() { return 1; }
7 };
8
9 template <class T>
10 struct B : A<T>
11 {
12 int f() { return 2; }
13
14 using A<T>::f;
15 void g()
16 {
17 if (A<T>::f() != 1 )
18 __builtin_abort();
19
20 if( B<T>::f() != 2 )
21 __builtin_abort();
22
23 if( this->f() != 2 )
24 __builtin_abort();
25 }
26 };
27
28 template <class T>
29 struct C
30 {
31 int h( int i ) { return 1; }
32 int h( double d ) { return 2; }
33 };
34
35 template <class T>
36 struct D : private C<T>
37 {
38 using C<T>::h;
39 int h( char c ) { return 0; }
40 int h() { return 3; }
41 };
42
43 int main()
44 {
45 B<int> b;
46 b.g();
47 b.f();
48 b.A<int>::f();
49 b.B<int>::f();
50
51 D<int> d;
52 if( d.h( 'a' ) != 0 )
53 __builtin_abort();
54
55 if( d.h( 3 ) != 1 )
56 __builtin_abort();
57
58 if( d.h( 3.14 ) != 2 )
59 __builtin_abort();
60
61 if( d.h() != 3 )
62 __builtin_abort();
63 }