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]

[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
--


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