re PR c++/65977 (Constexpr should be allowed in declaration of friend template specia...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 29 Jun 2015 22:02:08 +0000 (22:02 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Jun 2015 22:02:08 +0000 (22:02 +0000)
/cp
2015-06-29  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/65977
* decl.c (grokfndecl): Allow constexpr declarations of friend
template specializations.

/testsuite
2015-06-29  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/65977
* g++.dg/cpp0x/constexpr-friend-3.C: New.
* g++.dg/cpp0x/constexpr-friend-2.C: Adjust.

From-SVN: r225148

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C
gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C [new file with mode: 0644]

index aad780f6aea4bef593049b7c81eaa437ab8c86c2..843b7eda1767909dd4269b060166c00785267228 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-29  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/65977
+       * decl.c (grokfndecl): Allow constexpr declarations of friend
+       template specializations.
+
 2015-06-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR fortran/66605
index 3f1cd340e16afcae03f54a4d78c0949b48f0f536..5a644d7e2f4d3561caa45ffbabcc3370fb55cd01 100644 (file)
@@ -7738,15 +7738,12 @@ grokfndecl (tree ctype,
            }
 
          if (inlinep & 1)
-           error ("%<inline%> is not allowed in declaration of friend "
-                  "template specialization %qD",
-                  decl);
-         if (inlinep & 2)
-           error ("%<constexpr%> is not allowed in declaration of friend "
-                  "template specialization %qD",
-                  decl);
-         if (inlinep)
-           return NULL_TREE;
+           {
+             error ("%<inline%> is not allowed in declaration of friend "
+                    "template specialization %qD",
+                    decl);
+             return NULL_TREE;
+           }
        }
     }
 
index b4e9732fc0bfc06fc13d415cc22fe350793c1479..9c2f20b2c72db1bdb7f9242cfd126863eb97041b 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-29  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/65977
+       * g++.dg/cpp0x/constexpr-friend-3.C: New.
+       * g++.dg/cpp0x/constexpr-friend-2.C: Adjust.
+
 2015-06-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR fortran/66605
index 36799b435877c3b31242902521a1ea417e138c54..b2ddc218d4ab018c3eeda97755b4a1b422053696 100644 (file)
@@ -3,5 +3,5 @@
 template<typename T> void f(T);
 
 template <class T> class A {
-  friend constexpr void f<>(int);  // { dg-error "'constexpr' is not allowed" }
+  friend constexpr void f<>(int);
 };
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C
new file mode 100644 (file)
index 0000000..aec38eb
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/65977
+// { dg-do compile { target c++11 } }
+
+template<__SIZE_TYPE__>
+class bitset;
+
+template<__SIZE_TYPE__ N>
+constexpr bool operator==(const bitset<N>&, const bitset<N>&) noexcept;
+
+template<__SIZE_TYPE__ N>
+class bitset
+{
+  friend constexpr bool operator== <>(const bitset<N>&,
+                                     const bitset<N>&) noexcept;
+};
+
+template<__SIZE_TYPE__ N>
+constexpr bool operator==(const bitset<N>&, const bitset<N>&) noexcept
+{
+  return true;
+}