This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/57388 (ICE with ref-qualifier)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 23 May 2013 16:50:34 -0400
- Subject: C++ PATCH for c++/57388 (ICE with ref-qualifier)
This is a simple oversight in the ref-qualifier code.
Tested x86_64-pc-linux-gnu, applying to trunk. Jakub, is this OK for 4.8.1?
commit 0914d39b7335966f5d828c1b4225beb2e5448755
Author: Jason Merrill <jason@redhat.com>
Date: Thu May 23 14:01:27 2013 -0400
PR c++/57388
* tree.c (build_ref_qualified_type): Clear
FUNCTION_RVALUE_QUALIFIED for lvalue ref-qualifier.
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index e4967c1..a756634 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1754,8 +1754,10 @@ build_ref_qualified_type (tree type, cp_ref_qualifier rqual)
{
case REF_QUAL_RVALUE:
FUNCTION_RVALUE_QUALIFIED (t) = 1;
- /* Intentional fall through */
+ FUNCTION_REF_QUALIFIED (t) = 1;
+ break;
case REF_QUAL_LVALUE:
+ FUNCTION_RVALUE_QUALIFIED (t) = 0;
FUNCTION_REF_QUALIFIED (t) = 1;
break;
default:
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual13.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual13.C
new file mode 100644
index 0000000..84d3b0f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual13.C
@@ -0,0 +1,29 @@
+// PR c++/57388
+// { dg-require-effective-target c++11 }
+
+template<class> struct A
+{
+ static constexpr bool value = false;
+};
+
+template<class Res, class... Args>
+struct A<Res(Args...)>
+{
+ static constexpr bool value = true;
+};
+
+template<class Res, class... Args>
+struct A<Res(Args...) const &>
+{
+ static constexpr bool value = true;
+};
+
+template<class Res, class... Args>
+struct A<Res(Args...) const &&>
+{
+ static constexpr bool value = true;
+};
+
+static_assert(A<void()>::value, "Ouch");
+static_assert(A<void() const &>::value, ""); // #1
+static_assert(A<void() const &&>::value, ""); // #2