From 71506d4107f7cf3eef78bb9fa9743b7765e43fd9 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 29 Jun 2015 22:02:08 +0000 Subject: [PATCH] re PR c++/65977 (Constexpr should be allowed in declaration of friend template specialization) /cp 2015-06-29 Paolo Carlini PR c++/65977 * decl.c (grokfndecl): Allow constexpr declarations of friend template specializations. /testsuite 2015-06-29 Paolo Carlini 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 | 6 ++++++ gcc/cp/decl.c | 15 ++++++------- gcc/testsuite/ChangeLog | 6 ++++++ .../g++.dg/cpp0x/constexpr-friend-2.C | 2 +- .../g++.dg/cpp0x/constexpr-friend-3.C | 21 +++++++++++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aad780f6aea..843b7eda176 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-29 Paolo Carlini + + PR c++/65977 + * decl.c (grokfndecl): Allow constexpr declarations of friend + template specializations. + 2015-06-29 Manuel López-Ibáñez PR fortran/66605 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3f1cd340e16..5a644d7e2f4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7738,15 +7738,12 @@ grokfndecl (tree ctype, } if (inlinep & 1) - error ("% is not allowed in declaration of friend " - "template specialization %qD", - decl); - if (inlinep & 2) - error ("% is not allowed in declaration of friend " - "template specialization %qD", - decl); - if (inlinep) - return NULL_TREE; + { + error ("% is not allowed in declaration of friend " + "template specialization %qD", + decl); + return NULL_TREE; + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b4e9732fc0b..9c2f20b2c72 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-06-29 Paolo Carlini + + 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 PR fortran/66605 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C index 36799b43587..b2ddc218d4a 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-2.C @@ -3,5 +3,5 @@ template void f(T); template 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 index 00000000000..aec38eb68ff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-friend-3.C @@ -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&, const bitset&) noexcept; + +template<__SIZE_TYPE__ N> +class bitset +{ + friend constexpr bool operator== <>(const bitset&, + const bitset&) noexcept; +}; + +template<__SIZE_TYPE__ N> +constexpr bool operator==(const bitset&, const bitset&) noexcept +{ + return true; +} -- 2.30.2