diff options
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/template1.C | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7ea5b6f..a9fff08 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2003-01-01 Nathanael Nerode <neroden@gcc.gnu.org> + g++.dg/lookup/template1.C: New test. + g++.dg/parse/namespace2.C: New test. g++.dg/parse/parens2.C: New test. diff --git a/gcc/testsuite/g++.dg/lookup/template1.C b/gcc/testsuite/g++.dg/lookup/template1.C new file mode 100644 index 0000000..44b599a --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/template1.C @@ -0,0 +1,23 @@ +/* PR c++/3009 */ +/* { dg-do run } */ +// According to 14.6.2.4 of C++ Standard: +// "If a base class is a dependent type, a member of that +// class cannot hide a name declared within a template, or a +// name from the template's enclosing scopes." + +class B { +public: + int foo() { return 1; } +}; + +int foo() { return 0; } + +template <class T> class C : public T { +public: + int caller() { return foo(); } // This must be ::foo, not B::foo. +}; + +int main() { + C<B> c; + return c.caller(); // Returns 1 if we got the wrong one. +} |