This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++11][4.9] Add missing REDUC_PLUS_EXPR case to potential_constant_expression_1.


Hi,

As it stands, potential_constant_expression_1 does not handle
REDUC_PLUS_EXPR trees.

For some cross-lane add-reduce neon intrinsics we would like to
use the TARGET_FOLD_BUILTIN hook to fold these calls to a
REDUC_PLUS_EXPR. As an example, see Tejas Belagod's patch at:
http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00502.html

If we do that, the C++11 front-end is not able to evaluate
them as a potential constant expression and we get an
"unexpected AST of kind REDUC_PLUS_EXPR" error.

I am about as far from a C++11 expert as you can get, so I
don't know whether this is the correct fix, but to my naieve
mind I don't see why REDUC_PLUS_EXPR is different from any
other unary operator...

I have tested the patch on aarch64-none-elf with no regressions,
and it fixed the problem I was seeing previously.

Is this OK to commit to 4.9 when stage 1 opens up?

Thanks,
James Greenhalgh

---
gcc/cp/

	* semantics.c
	(potential_constant_expression_1): Add case for REDUC_PLUS_EXPR.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 9446f83..232057a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8600,6 +8600,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
     case ABS_EXPR:
     case TRUTH_NOT_EXPR:
     case FIXED_CONVERT_EXPR:
+    case REDUC_PLUS_EXPR:
     case UNARY_PLUS_EXPR:
       return potential_constant_expression_1 (TREE_OPERAND (t, 0), rval,
 					      flags);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]