diff mbox

[C++] PR 67926 ("Using folding expressions in a constexpr context ice's")

Message ID 561F9381.2080407@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 15, 2015, 11:52 a.m. UTC
Hi,

this one seems simple, matter of handling the relevant tree codes. 
Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////
/cp
2015-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67926
	* constexpr.c (potential_constant_expression_1): Handle
	UNARY_LEFT_FOLD_EXPR, UNARY_RIGHT_FOLD_EXPR, BINARY_LEFT_FOLD_EXPR,
	BINARY_RIGHT_FOLD_EXPR.

/testsuite
2015-10-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67926
	* g++.dg/cpp1z/fold-ice1.C: New.

Comments

Jason Merrill Oct. 15, 2015, 11:23 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/constexpr.c
===================================================================
--- cp/constexpr.c	(revision 228840)
+++ cp/constexpr.c	(working copy)
@@ -4385,6 +4385,8 @@  potential_constant_expression_1 (tree t, bool want
     case TRUTH_NOT_EXPR:
     case FIXED_CONVERT_EXPR:
     case UNARY_PLUS_EXPR:
+    case UNARY_LEFT_FOLD_EXPR:
+    case UNARY_RIGHT_FOLD_EXPR:
     unary:
       return RECUR (TREE_OPERAND (t, 0), rval);
 
@@ -4565,6 +4567,8 @@  potential_constant_expression_1 (tree t, bool want
     case MEMBER_REF:
     case DOTSTAR_EXPR:
     case MEM_REF:
+    case BINARY_LEFT_FOLD_EXPR:
+    case BINARY_RIGHT_FOLD_EXPR:
     binary:
       for (i = 0; i < 2; ++i)
 	if (!RECUR (TREE_OPERAND (t, i), want_rval))
Index: testsuite/g++.dg/cpp1z/fold-ice1.C
===================================================================
--- testsuite/g++.dg/cpp1z/fold-ice1.C	(revision 0)
+++ testsuite/g++.dg/cpp1z/fold-ice1.C	(working copy)
@@ -0,0 +1,8 @@ 
+// PR c++/67926
+// { dg-options -std=c++1z }
+
+template <bool ... T> bool FUR = (T && ...);
+template <bool ... T> bool FUL = (... && T);
+
+template <bool T1, bool ... T2> bool FBR = (T1 && ... && T2);
+template <bool T1, bool ... T2> bool FBL = (T2 && ... && T1);