This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Committed] PR c++/19355
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Jan 2005 15:26:42 -0700 (MST)
- Subject: [Committed] PR c++/19355
The following patch fixes PR c++/19355 which is a silly oversight in my
recent patch to c_common_truthvalue_conversion. I failed to notice that
mixed in with all of the comparison operators and the binary Boolean
operators in c_common_truthvalue_conversion's switch statement was a
lone unary TRUTH_NOT_EXPR. The following "obvious" patch splits this
out into it's own "case" clause. My apologies for any inconvenience.
The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.
Committed to mainline CVS as obvious.
2005-01-10 Roger Sayle <roger@eyesopen.com>
PR c++/19355
* c-common.c (c_common_truthvalue_conversion): TRUTH_NOT_EXPR is a
unary operator and can't be treated as a binary/comparison operator.
* g++.dg/expr/pr19355-1.C: New test case.
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.597
diff -c -3 -p -r1.597 c-common.c
*** c-common.c 7 Jan 2005 20:05:03 -0000 1.597
--- c-common.c 10 Jan 2005 18:43:07 -0000
*************** c_common_truthvalue_conversion (tree exp
*** 2326,2337 ****
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
- case TRUTH_NOT_EXPR:
if (TREE_TYPE (expr) != truthvalue_type_node)
return build2 (TREE_CODE (expr), truthvalue_type_node,
TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
return expr;
case ERROR_MARK:
return expr;
--- 2326,2342 ----
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
if (TREE_TYPE (expr) != truthvalue_type_node)
return build2 (TREE_CODE (expr), truthvalue_type_node,
TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1));
return expr;
+ case TRUTH_NOT_EXPR:
+ if (TREE_TYPE (expr) != truthvalue_type_node)
+ return build1 (TREE_CODE (expr), truthvalue_type_node,
+ TREE_OPERAND (expr, 0));
+ return expr;
+
case ERROR_MARK:
return expr;
// PR c++/19355
// { dg-do compile }
typedef bool Boolean;
extern Boolean is_nil ();
void f(void)
{
unsigned int ilen;
if(!((ilen > 0 ? !is_nil () : 1))) {}
}
Roger
--