Patchwork C++ PATCH for c++/57388 (ICE with ref-qualifier)

login
register
mail settings
Submitter Jason Merrill
Date May 23, 2013, 8:50 p.m.
Message ID <519E811A.7020801@redhat.com>
Download mbox | patch
Permalink /patch/246023/
State New
Headers show

Comments

Jason Merrill - May 23, 2013, 8:50 p.m.
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?
Jakub Jelinek - May 24, 2013, 1:16 p.m.
On Thu, May 23, 2013 at 04:50:34PM -0400, Jason Merrill wrote:
> 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?

Ok, thanks.

> 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.

	Jakub

Patch

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