From patchwork Thu Oct 4 15:20:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [C++,testcase] PR 54323 Date: Thu, 04 Oct 2012 05:20:51 -0000 From: Paolo Carlini X-Patchwork-Id: 189189 Message-Id: <506DA953.8080203@oracle.com> To: "gcc-patches@gcc.gnu.org" Hi, I'm adding the testcase and closing the PR. Tested x86_64-linux. Thanks, Paolo. ///////////////////////// 2012-10-04 Paolo Carlini PR c++/54323 * g++.dg/cpp0x/pr54323.C: New. Index: g++.dg/cpp0x/pr54323.C =================================================================== --- g++.dg/cpp0x/pr54323.C (revision 0) +++ g++.dg/cpp0x/pr54323.C (working copy) @@ -0,0 +1,37 @@ +// PR c++/54323 +// { dg-do compile { target c++11 } } + +template +struct enable_if { }; + +template +struct enable_if +{ typedef T type; }; + +template class CRTP, typename T> +class Base +{ +public: + template class CRTP0, typename T0, class> + friend int func(const Base& rhs); + +protected: + int n; +}; + +template class CRTP0, typename T0, + class = typename enable_if::type> +int func(const Base& rhs) +{ + return rhs.n; +} + +template +class Derived : public Base {}; + +int main() +{ + Derived x; + func(x); + return 0; +}