diff mbox

[c++-concepts] Restore missing code from previous trunk merge

Message ID 54D4489B.8000007@maniacsvault.net
State New
Headers show

Commit Message

Braden Obrzut Feb. 6, 2015, 4:52 a.m. UTC
A little bit of code went missing due to the constant expressions code 
being factored out.  Additionally, concepts are currently dependent on 
changes to CPTK_IS_CONVERTIBLE_TO, so this patch restores that.  I'm 
told that this was removed from trunk and that the concepts branch will 
be adapted to follow suit, but for now it fixes a regression with 
compound requirements.

- Braden Obrzut

2015-02-05  Braden Obrzut  <admin@maniacsvault.net>

     * gcc/cp/constexpr.c (potential_constant_expression_1): Readded missing
     cases from previous merge from trunk.
     * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Restored
     CPTK_IS_CONVERTIBLE_TO for the time being since the constraint code
     relies on it.
     * gcc/cp/semantics.c (finish_trait_expr): Likewise.
     * gcc/testsuite/g++.dg/concepts/req9.C: New test.
diff mbox

Patch

Index: gcc/cp/constexpr.c
===================================================================
--- gcc/cp/constexpr.c	(revision 220468)
+++ gcc/cp/constexpr.c	(working copy)
@@ -3021,6 +3021,13 @@ 
     case PARM_DECL:
     case USING_DECL:
     case PLACEHOLDER_EXPR:
+    case REQUIRES_EXPR:
+    case EXPR_REQ:
+    case TYPE_REQ:
+    case NESTED_REQ:
+    case VALIDEXPR_EXPR:
+    case VALIDTYPE_EXPR:
+    case CONSTEXPR_EXPR:
       return true;
 
     case AGGR_INIT_EXPR:
Index: gcc/cp/cxx-pretty-print.c
===================================================================
--- gcc/cp/cxx-pretty-print.c	(revision 220468)
+++ gcc/cp/cxx-pretty-print.c	(working copy)
@@ -2490,6 +2490,9 @@ 
     case CPTK_IS_CLASS:
       pp_cxx_ws_string (pp, "__is_class");
       break;
+    case CPTK_IS_CONVERTIBLE_TO:
+      pp_cxx_ws_string (pp, "__is_convertible_to");
+      break;
     case CPTK_IS_EMPTY:
       pp_cxx_ws_string (pp, "__is_empty");
       break;
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c	(revision 220468)
+++ gcc/cp/semantics.c	(working copy)
@@ -7629,7 +7629,8 @@ 
     case CPTK_IS_UNION:
     case CPTK_IS_SAME_AS:
       break;
-    
+
+    case CPTK_IS_CONVERTIBLE_TO:
       if (!check_trait_type (type1))
         return error_mark_node;
       if (!check_trait_type (type2))
Index: gcc/testsuite/g++.dg/concepts/req9.C
===================================================================
--- gcc/testsuite/g++.dg/concepts/req9.C	(revision 0)
+++ gcc/testsuite/g++.dg/concepts/req9.C	(working copy)
@@ -0,0 +1,24 @@ 
+// { dg-options "-std=c++1z" }
+
+template<typename T>
+struct S1 {};
+
+template<typename T>
+concept bool C() { return requires(T x) { { x.fn() } -> S1<T>; }; }
+
+template<C U>
+void fn(U x)
+{
+  x.fn();
+}
+
+struct S2
+{
+  auto fn() const { return S1<S2>(); }
+};
+
+int main()
+{
+  fn(S2{});
+  return 0;
+}