re PR c++/57388 ([C++11] ICE when function types with ref-qualifiers meet other funct...
authorJason Merrill <jason@redhat.com>
Thu, 23 May 2013 20:51:22 +0000 (16:51 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 May 2013 20:51:22 +0000 (16:51 -0400)
PR c++/57388
* tree.c (build_ref_qualified_type): Clear
FUNCTION_RVALUE_QUALIFIED for lvalue ref-qualifier.

From-SVN: r199269

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/ref-qual13.C [new file with mode: 0644]

index 7025f34..885d4c9 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-23  Jason Merrill  <jason@redhat.com>
+
+       PR c++/57388
+       * tree.c (build_ref_qualified_type): Clear
+       FUNCTION_RVALUE_QUALIFIED for lvalue ref-qualifier.
+
 2013-05-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/56930
index 9c324e3..0fbb33d 100644 (file)
@@ -1769,8 +1769,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 (file)
index 0000000..84d3b0f
--- /dev/null
@@ -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