From a970c57771c362c78925e9a9740a02bbf7d4b921 Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 11 Dec 2009 02:55:56 +0000 Subject: [PATCH] Test member template using hiding. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91099 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../basic.namespace/namespace.udecl/p12.cpp | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp index 30d43ec365..4cbe1be056 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp @@ -1,4 +1,4 @@ -// RUN: clang -fsyntax-only -verify %s +// RUN: clang-cc -fsyntax-only -verify %s // C++03 [namespace.udecl]p12: // When a using-declaration brings names from a base class into a @@ -6,6 +6,9 @@ // override and/or hide member functions with the same name and // parameter types in a base class (rather than conflicting). +template struct Opaque {}; +template void expect(Opaque _) {} + // PR5727 // This just shouldn't crash. namespace test0 { @@ -21,7 +24,6 @@ namespace test0 { // Simple hiding. namespace test1 { - template struct Opaque {}; struct Base { Opaque<0> foo(Opaque<0>); Opaque<0> foo(Opaque<1>); @@ -99,3 +101,44 @@ namespace test2 { d2.testUnresolved(i); } } + +// Hiding of member templates. +namespace test3 { + struct Base { + template Opaque<0> foo() { return Opaque<0>(); } + template Opaque<1> foo() { return Opaque<1>(); } + }; + + struct Derived1 : Base { + using Base::foo; + template Opaque<2> foo() { return Opaque<2>(); } + }; + + struct Derived2 : Base { + template Opaque<2> foo() { return Opaque<2>(); } + using Base::foo; + }; + + struct Derived3 : Base { + using Base::foo; + template Opaque<3> foo() { return Opaque<3>(); } + }; + + struct Derived4 : Base { + template Opaque<3> foo() { return Opaque<3>(); } + using Base::foo; + }; + + void test() { + expect<0>(Base().foo()); + expect<1>(Base().foo<0>()); + expect<0>(Derived1().foo()); + expect<2>(Derived1().foo<0>()); + expect<0>(Derived2().foo()); + expect<2>(Derived2().foo<0>()); + expect<3>(Derived3().foo()); + expect<1>(Derived3().foo<0>()); + expect<3>(Derived4().foo()); + expect<1>(Derived4().foo<0>()); + } +}