[C++] Handle TRUTH_XOR_EXPR in potential_constant_expression_1 (PR c++/47476)

Submitted by Jakub Jelinek on Jan. 26, 2011, 7:40 p.m.

Details

Message ID 20110126194023.GL2724@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 26, 2011, 7:40 p.m.
Hi!

The folder creates TRUTH_XOR_EXPR out of NE_EXPR with truth values
on both sides, but potential_constant_expression_1 ICEs on it,
as it doesn't handle that tree code.

Fixed by treating it like other binary expressions (including
NE_EXPR/EQ_EXPR if we know that the arguments aren't two pointers),
bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-01-26  Jakub Jelinek  <jakub@redhat.com>

	PR c++/47476
	* semantics.c (potential_constant_expression_1): Handle
	TRUTH_XOR_EXPR.

	* g++.dg/cpp0x/pr47476.C: New test.


	Jakub

Comments

Jason Merrill Jan. 26, 2011, 9:18 p.m.
OK.

Jason

Patch hide | download patch | download mbox

--- gcc/cp/semantics.c.jj	2011-01-26 07:45:33.000000000 +0100
+++ gcc/cp/semantics.c	2011-01-26 17:32:42.863546187 +0100
@@ -7656,6 +7656,7 @@  potential_constant_expression_1 (tree t,
     case BIT_IOR_EXPR:
     case BIT_XOR_EXPR:
     case BIT_AND_EXPR:
+    case TRUTH_XOR_EXPR:
     case UNLT_EXPR:
     case UNLE_EXPR:
     case UNGT_EXPR:
--- gcc/testsuite/g++.dg/cpp0x/pr47476.C.jj	2011-01-26 17:38:24.493482589 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr47476.C	2011-01-26 17:38:59.189401986 +0100
@@ -0,0 +1,10 @@ 
+// PR c++/47476
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+int
+foo (int a, int b)
+{
+  const bool c ((a != 0) == (b != 26));
+  return c;
+}