| 1 |
// { dg-do run } |
| 2 |
// 981203 bkoz |
| 3 |
// g++/14687 |
| 4 |
|
| 5 |
#include <assert.h> |
| 6 |
unsigned int gtest; |
| 7 |
|
| 8 |
// 7.3.3 the using declaration |
| 9 |
|
| 10 |
// p 3 |
| 11 |
struct belieze { |
| 12 |
void f(char); |
| 13 |
void g(char); |
| 14 |
enum E { e }; |
| 15 |
union { int x; }; |
| 16 |
}; |
| 17 |
|
| 18 |
struct dominica: belieze { |
| 19 |
using belieze::f; |
| 20 |
void f(int i) { f('c'); } // calls belieze::f(char) |
| 21 |
void g(int i) { g('c'); } // recursively calls dominca::g(int) |
| 22 |
}; |
| 23 |
|
| 24 |
|
| 25 |
// p 6 |
| 26 |
namespace A { |
| 27 |
void f(int i) { gtest = 1; } |
| 28 |
} |
| 29 |
|
| 30 |
using A::f; //f is a synonym for A::f, that is for A::f(int) |
| 31 |
|
| 32 |
namespace A { |
| 33 |
void f(char c) { gtest = 3; } |
| 34 |
} |
| 35 |
|
| 36 |
void foo(void) { |
| 37 |
f('a'); //calls f(int), even though A::f(char) exits |
| 38 |
assert (gtest = 1); |
| 39 |
} |
| 40 |
|
| 41 |
void bar(void) { |
| 42 |
using A::f; //f is a synonm for A::f, that is for A::f(int) and A::f(char) |
| 43 |
f('a'); //calls f(char) |
| 44 |
assert (gtest = 3); |
| 45 |
} |
| 46 |
|
| 47 |
int main(void) |
| 48 |
{ |
| 49 |
foo(); |
| 50 |
bar(); |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |