aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2014-09-18 09:15:25 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2014-09-18 09:15:25 +0000
commit2a2c9357f625428880a29be77729674f4703c9fa (patch)
tree664cef3cbfd3a683460a8c2d5531c625a4c17168 /gcc
parent1d2af9939b50d3de89b5c8f7166b6b8010a206e4 (diff)
downloadgcc-2a2c9357f625428880a29be77729674f4703c9fa.zip
gcc-2a2c9357f625428880a29be77729674f4703c9fa.tar.gz
gcc-2a2c9357f625428880a29be77729674f4703c9fa.tar.bz2
re PR c++/61745 (template friend for dyadic operator- is only accepted if the monadic operator- follows it)
2014-09-18 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61745 * g++.dg/template/pr61745.C: New. From-SVN: r215345
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/pr61745.C22
2 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2815792..60a402f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-18 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61745
+ * g++.dg/template/pr61745.C: New.
+
2014-09-17 Marek Polacek <polacek@redhat.com>
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 0000000..0f7c280
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr61745.C
@@ -0,0 +1,22 @@
+// PR c++/61745
+
+template <typename INT,INT P> class Zp;
+
+template <typename INT,INT P>
+Zp<INT,P> operator-(const Zp<INT,P>& a, const Zp<INT,P>& b);
+
+template <typename INT,INT P>
+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<INT,P> operator- <>(const Zp<INT,P>& a, const Zp<INT,P>& b); // { dg-error "declaration|expected" }
+};