From: Paolo Carlini Date: Thu, 18 Sep 2014 09:15:25 +0000 (+0000) Subject: re PR c++/61745 (template friend for dyadic operator- is only accepted if the monadic... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2a2c9357f625428880a29be77729674f4703c9fa;p=gcc.git re PR c++/61745 (template friend for dyadic operator- is only accepted if the monadic operator- follows it) 2014-09-18 Paolo Carlini PR c++/61745 * g++.dg/template/pr61745.C: New. From-SVN: r215345 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 28157924c47..60a402f1243 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-18 Paolo Carlini + + PR c++/61745 + * g++.dg/template/pr61745.C: New. + 2014-09-17 Marek Polacek PR c/61854 diff --git a/gcc/testsuite/g++.dg/template/pr61745.C b/gcc/testsuite/g++.dg/template/pr61745.C new file mode 100644 index 00000000000..0f7c280e52a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr61745.C @@ -0,0 +1,22 @@ +// PR c++/61745 + +template class Zp; + +template +Zp operator-(const Zp& a, const Zp& b); + +template +class Zp { +public: + static const INT p = P; +private: + INT val; +public: + Zp() : val(0) {} + Zp( INT x ) : val(x%p) { if (x < 0 ) x+= p; } + + // this compiles only if the following definition is moved + // AFTER the friend declaration + Zp operator-() const { return Zp(p-val); } + friend Zp operator- <>(const Zp& a, const Zp& b); // { dg-error "declaration|expected" } +};