[PATCH] Fix PR23794, wrong types from the C++ frontend for COND_EXPRs

Richard Guenther rguenther@suse.de
Fri Aug 11 22:30:00 GMT 2006


This is an old fix fixing a latent type problem in the C++ frontend
that caused PR23624 which was since fixed by extra checks in the
middle-end.

This was bootstrapped and tested on x86_64-unknown-linux-gnu.  I will
repeat testing before applying.

Ok for the mainline after we branched for 4.2?

Thanks,
Richard.

:ADDPATCH C++:

2005-08-30  Richard Guenther  <rguenther@suse.de>

	PR c++/23794
	* pt.c (build_non_dependent_expr): Apply implicit conversion
	to conditional of COND_EXPR.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.1027
diff -c -3 -p -r1.1027 pt.c
*** cp/pt.c	29 Aug 2005 14:08:35 -0000	1.1027
--- cp/pt.c	30 Aug 2005 09:40:52 -0000
*************** build_non_dependent_expr (tree expr)
*** 12596,12608 ****
      return expr;
  
    if (TREE_CODE (expr) == COND_EXPR)
!     return build3 (COND_EXPR,
! 		   TREE_TYPE (expr),
! 		   TREE_OPERAND (expr, 0),
! 		   (TREE_OPERAND (expr, 1)
! 		    ? build_non_dependent_expr (TREE_OPERAND (expr, 1))
! 		    : build_non_dependent_expr (TREE_OPERAND (expr, 0))),
! 		   build_non_dependent_expr (TREE_OPERAND (expr, 2)));
    if (TREE_CODE (expr) == COMPOUND_EXPR
        && !COMPOUND_EXPR_OVERLOADED (expr))
      return build2 (COMPOUND_EXPR,
--- 12596,12612 ----
      return expr;
  
    if (TREE_CODE (expr) == COND_EXPR)
!     {
!       tree cond = perform_implicit_conversion (boolean_type_node,
! 					       TREE_OPERAND (expr, 0));
!       return build3 (COND_EXPR,
! 		     TREE_TYPE (expr),
! 		     cond,
! 		     (TREE_OPERAND (expr, 1)
! 		      ? build_non_dependent_expr (TREE_OPERAND (expr, 1))
! 		      : build_non_dependent_expr (TREE_OPERAND (expr, 0))),
! 		     build_non_dependent_expr (TREE_OPERAND (expr, 2)));
!     }
    if (TREE_CODE (expr) == COMPOUND_EXPR
        && !COMPOUND_EXPR_OVERLOADED (expr))
      return build2 (COMPOUND_EXPR,



More information about the Gcc-patches mailing list