Debian Codegraph @

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

raw
1 /* PR c++/3009 */
2 /* { dg-do run } */
3 // According to 14.6.2.4 of C++ Standard:
4 // "If a base class is a dependent type, a member of that
5 // class cannot hide a name declared within a template, or a
6 // name from the template's enclosing scopes."
7
8 class B {
9 public:
10 int foo() { return 1; }
11 };
12
13 int foo() { return 0; }
14
15 template <class T> class C : public T {
16 public:
17 int caller() { return foo(); } // This must be ::foo, not B::foo.
18 };
19
20 int main() {
21 C<B> c;
22 return c.caller(); // Returns 1 if we got the wrong one.
23 }