From 2a2c9357f625428880a29be77729674f4703c9fa Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 18 Sep 2014 09:15:25 +0000 Subject: [PATCH] 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 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/pr61745.C | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/pr61745.C 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" } +}; -- 2.30.2