From c62b924434c30cc417df9c1f0bac770e653f0241 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 4 Oct 2012 15:19:34 +0000 Subject: [PATCH] re PR c++/54323 (Friend function declaration not correctly identified with CRTP + enable_if) 2012-10-04 Paolo Carlini PR c++/54323 * g++.dg/cpp0x/pr54323.C: New. From-SVN: r192083 --- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/cpp0x/pr54323.C | 37 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr54323.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b6963efa28..306d277187a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-10-04 Paolo Carlini + + PR c++/54323 + * g++.dg/cpp0x/pr54323.C: New. + 2012-10-04 Richard Guenther PR middle-end/54735 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr54323.C b/gcc/testsuite/g++.dg/cpp0x/pr54323.C new file mode 100644 index 00000000000..71b6c7192df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr54323.C @@ -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; +}