Patches to remove truthvalue_conversion langhook

Joseph S. Myers joseph@codesourcery.com
Wed Mar 23 01:43:00 GMT 2005


This pair of patches remove the truthvalue_conversion langhook.  It is
called in only one place in language-independent code, in
gimple_boolify, and it seems to me that front ends should ensure that
COND_EXPRs have a proper truthvalue condition rather than using a
langhook like this; in fact it seems they already do.

The first patch cleans up truthvalue_conversion for the C front end.
This distinguishes between c_objc_common_truthvalue_conversion (cares
about whether arrays are lvalues, validates that the type is suitable)
and c_common_truthvalue_conversion (does not check the type or perform
default conversions and gives a confusing diagnostic if the type is
wrong).  Calls are changed to call the appropriate alternative; the
langhook is changed to c_common_truthvalue_conversion (which is its
value for C++).  Bootstrapped with no regressions on
x86_64-unknown-linux-gnu.  Applied to mainline.

The second patch removes the langhook.  Bootstrapped (together with
the first patch) with no regressions on i686-pc-linux-gnu, all
languages including ada and treelang.  OK to commit?

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)

2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* c-common.c (c_common_truthvalue_conversion): Adjust comment.
	Call c_common_truthvalue_conversion rather than
	lang_hooks.truthvalue_conversion.
	* c-convert.c (convert): Call c_objc_common_truthvalue_conversion.
	* c-objc-common.c (c_objc_common_truthvalue_conversion): Move to
	c-typeck.c.
	* c-objc-common.h (LANG_HOOKS_TRUTHVALUE_CONVERSION): Change to
	c_common_truthvalue_conversion.
	* c-parser.c (c_parser_paren_condition, c_parser_for_statement,
	c_parser_conditional_expression, c_parser_binary_expression): Call
	c_objc_common_truthvalue_conversion.
	* c-typeck.c (build_unary_op): Call
	c_objc_common_truthvalue_conversion.
	(build_conditional_expr): Do not call
	lang_hooks.truthvalue_conversion.
	(build_binary_op): Call c_common_truthvalue_conversion.
	(c_objc_common_truthvalue_conversion): Moved from
	c-objc-common.c.  Call default_function_array_conversion instead
	of default_conversion.

objc:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* objc-act.c (next_sjlj_build_enter_and_setjmp,
	next_sjlj_build_catch_list, next_sjlj_build_try_catch_finally):
	Call c_common_truthvalue_conversion.

diff -rupN GCC.orig/gcc/c-common.c GCC/gcc/c-common.c
--- GCC.orig/gcc/c-common.c	2005-03-21 17:55:02.000000000 +0000
+++ GCC/gcc/c-common.c	2005-03-22 18:20:15.000000000 +0000
@@ -2314,7 +2314,9 @@ pointer_int_sum (enum tree_code resultco
 }
 
 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
-   or validate its data type for an `if' or `while' statement or ?..: exp.
+   or for an `if' or `while' statement or ?..: exp.  It should already
+   have been validated to be of suitable type; otherwise, a bad
+   diagnostic may result.
 
    This preparation consists of taking the ordinary
    representation of an expression expr and producing a valid tree
@@ -2346,14 +2348,14 @@ c_common_truthvalue_conversion (tree exp
       if (TREE_TYPE (expr) == truthvalue_type_node)
 	return expr;
       return build2 (TREE_CODE (expr), truthvalue_type_node,
-		 lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)),
-		 lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 1)));
+		 c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)),
+		 c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)));
 
     case TRUTH_NOT_EXPR:
       if (TREE_TYPE (expr) == truthvalue_type_node)
 	return expr;
       return build1 (TREE_CODE (expr), truthvalue_type_node,
-		 lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)));
+		 c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
 
     case ERROR_MARK:
       return expr;
@@ -2401,15 +2403,15 @@ c_common_truthvalue_conversion (tree exp
     case COMPLEX_EXPR:
       return build_binary_op ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
 			       ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-		lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)),
-		lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 1)),
+		c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)),
+		c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
 			      0);
 
     case NEGATE_EXPR:
     case ABS_EXPR:
     case FLOAT_EXPR:
       /* These don't change whether an object is nonzero or zero.  */
-      return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
+      return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case LROTATE_EXPR:
     case RROTATE_EXPR:
@@ -2418,16 +2420,16 @@ c_common_truthvalue_conversion (tree exp
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
 	return build2 (COMPOUND_EXPR, truthvalue_type_node,
 		       TREE_OPERAND (expr, 1),
-		       lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)));
+		       c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
       else
-	return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
+	return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       return fold (build3 (COND_EXPR, truthvalue_type_node,
 		TREE_OPERAND (expr, 0),
-		lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 1)),
-		lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 2))));
+		c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+		c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))));
 
     case CONVERT_EXPR:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
@@ -2440,7 +2442,7 @@ c_common_truthvalue_conversion (tree exp
       /* If this is widening the argument, we can ignore it.  */
       if (TYPE_PRECISION (TREE_TYPE (expr))
 	  >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
-	return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
+	return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
       break;
 
     case MINUS_EXPR:
@@ -2489,8 +2491,8 @@ c_common_truthvalue_conversion (tree exp
       return (build_binary_op
 	      ((TREE_SIDE_EFFECTS (expr)
 		? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-	lang_hooks.truthvalue_conversion (build_unary_op (REALPART_EXPR, t, 0)),
-	lang_hooks.truthvalue_conversion (build_unary_op (IMAGPART_EXPR, t, 0)),
+	c_common_truthvalue_conversion (build_unary_op (REALPART_EXPR, t, 0)),
+	c_common_truthvalue_conversion (build_unary_op (IMAGPART_EXPR, t, 0)),
 	       0));
     }
 
diff -rupN GCC.orig/gcc/c-convert.c GCC/gcc/c-convert.c
--- GCC.orig/gcc/c-convert.c	2005-02-01 22:40:58.000000000 +0000
+++ GCC/gcc/c-convert.c	2005-03-22 12:28:29.000000000 +0000
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - S
 #include "flags.h"
 #include "convert.h"
 #include "c-common.h"
+#include "c-tree.h"
 #include "langhooks.h"
 #include "toplev.h"
 
@@ -95,7 +96,7 @@ convert (tree type, tree expr)
     return fold (convert_to_integer (type, e));
   if (code == BOOLEAN_TYPE)
     {
-      tree t = lang_hooks.truthvalue_conversion (expr);
+      tree t = c_objc_common_truthvalue_conversion (expr);
       if (TREE_CODE (t) == ERROR_MARK)
 	return t;
 
diff -rupN GCC.orig/gcc/c-objc-common.c GCC/gcc/c-objc-common.c
--- GCC.orig/gcc/c-objc-common.c	2005-02-01 22:40:59.000000000 +0000
+++ GCC/gcc/c-objc-common.c	2005-03-22 18:14:22.000000000 +0000
@@ -230,34 +230,6 @@ c_tree_printer (pretty_printer *pp, text
   return true;
 }
 
-tree
-c_objc_common_truthvalue_conversion (tree expr)
-{
- retry:
-  switch (TREE_CODE (TREE_TYPE (expr)))
-    {
-    case ARRAY_TYPE:
-      expr = default_conversion (expr);
-      if (TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
-	goto retry;
-
-      error ("used array that cannot be converted to pointer where scalar is required");
-      return error_mark_node;
-
-    case RECORD_TYPE:
-      error ("used struct type value where scalar is required");
-      return error_mark_node;
-
-    case UNION_TYPE:
-      error ("used union type value where scalar is required");
-      return error_mark_node;
-    default:
-      break;
-    }
-
-  return c_common_truthvalue_conversion (expr);
-}
-
 /* In C and ObjC, all decls have "C" linkage.  */
 bool
 has_c_linkage (tree decl ATTRIBUTE_UNUSED)
diff -rupN GCC.orig/gcc/c-objc-common.h GCC/gcc/c-objc-common.h
--- GCC.orig/gcc/c-objc-common.h	2005-02-23 23:43:17.000000000 +0000
+++ GCC/gcc/c-objc-common.h	2005-03-21 22:06:24.000000000 +0000
@@ -53,7 +53,7 @@ extern void c_initialize_diagnostics (di
 #undef LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
 #undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_objc_common_truthvalue_conversion
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
diff -rupN GCC.orig/gcc/c-parser.c GCC/gcc/c-parser.c
--- GCC.orig/gcc/c-parser.c	2005-03-20 15:21:10.000000000 +0000
+++ GCC/gcc/c-parser.c	2005-03-22 18:24:49.000000000 +0000
@@ -3580,7 +3580,8 @@ c_parser_paren_condition (c_parser *pars
   if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
     return error_mark_node;
   loc = c_parser_peek_token (parser)->location;
-  cond = lang_hooks.truthvalue_conversion (c_parser_expression (parser).value);
+  cond = c_objc_common_truthvalue_conversion
+    (c_parser_expression (parser).value);
   if (EXPR_P (cond))
     SET_EXPR_LOCATION (cond, loc);
   c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
@@ -3816,7 +3817,7 @@ c_parser_for_statement (c_parser *parser
       else
 	{
 	  tree ocond = c_parser_expression (parser).value;
-	  cond = lang_hooks.truthvalue_conversion (ocond);
+	  cond = c_objc_common_truthvalue_conversion (ocond);
 	  if (EXPR_P (cond))
 	    SET_EXPR_LOCATION (cond, loc);
 	  c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
@@ -4151,13 +4152,14 @@ c_parser_conditional_expression (c_parse
 	pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
       /* Make sure first operand is calculated only once.  */
       exp1.value = save_expr (default_conversion (cond.value));
-      cond.value = lang_hooks.truthvalue_conversion (exp1.value);
+      cond.value = c_objc_common_truthvalue_conversion (exp1.value);
       skip_evaluation += cond.value == truthvalue_true_node;
     }
   else
     {
       cond.value
-	= lang_hooks.truthvalue_conversion (default_conversion (cond.value));
+	= c_objc_common_truthvalue_conversion
+	(default_conversion (cond.value));
       skip_evaluation += cond.value == truthvalue_false_node;
       exp1 = c_parser_expression (parser);
       skip_evaluation += ((cond.value == truthvalue_true_node)
@@ -4394,12 +4396,12 @@ c_parser_binary_expression (c_parser *pa
       switch (ocode)
 	{
 	case TRUTH_ANDIF_EXPR:
-	  stack[sp].expr.value = lang_hooks.truthvalue_conversion
+	  stack[sp].expr.value = c_objc_common_truthvalue_conversion
 	    (default_conversion (stack[sp].expr.value));
 	  skip_evaluation += stack[sp].expr.value == truthvalue_false_node;
 	  break;
 	case TRUTH_ORIF_EXPR:
-	  stack[sp].expr.value = lang_hooks.truthvalue_conversion
+	  stack[sp].expr.value = c_objc_common_truthvalue_conversion
 	    (default_conversion (stack[sp].expr.value));
 	  skip_evaluation += stack[sp].expr.value == truthvalue_true_node;
 	  break;
diff -rupN GCC.orig/gcc/c-typeck.c GCC/gcc/c-typeck.c
--- GCC.orig/gcc/c-typeck.c	2005-03-21 02:18:50.000000000 +0000
+++ GCC/gcc/c-typeck.c	2005-03-22 18:33:12.000000000 +0000
@@ -2540,6 +2540,8 @@ build_unary_op (enum tree_code code, tre
       break;
 
     case TRUTH_NOT_EXPR:
+      /* ??? Why do most validation here but that for non-lvalue arrays
+	 in c_objc_common_truthvalue_conversion?  */
       if (typecode != INTEGER_TYPE
 	  && typecode != REAL_TYPE && typecode != POINTER_TYPE
 	  && typecode != COMPLEX_TYPE
@@ -2549,7 +2551,7 @@ build_unary_op (enum tree_code code, tre
 	  error ("wrong type argument to unary exclamation mark");
 	  return error_mark_node;
 	}
-      arg = lang_hooks.truthvalue_conversion (arg);
+      arg = c_objc_common_truthvalue_conversion (arg);
       return invert_truthvalue (arg);
 
     case NOP_EXPR:
@@ -2905,8 +2907,6 @@ build_conditional_expr (tree ifexp, tree
   tree result_type = NULL;
   tree orig_op1 = op1, orig_op2 = op2;
 
-  ifexp = lang_hooks.truthvalue_conversion (default_conversion (ifexp));
-
   /* Promote both alternatives.  */
 
   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
@@ -7295,8 +7295,8 @@ build_binary_op (enum tree_code code, tr
 	     but that does not mean the operands should be
 	     converted to ints!  */
 	  result_type = integer_type_node;
-	  op0 = lang_hooks.truthvalue_conversion (op0);
-	  op1 = lang_hooks.truthvalue_conversion (op1);
+	  op0 = c_common_truthvalue_conversion (op0);
+	  op1 = c_common_truthvalue_conversion (op1);
 	  converted = 1;
 	}
       break;
@@ -7776,3 +7776,34 @@ build_binary_op (enum tree_code code, tr
     return result;
   }
 }
+
+
+/* Convert EXPR to be a truth-value, validating its type for this
+   purpose.  Passes EXPR to default_function_array_conversion.  */
+
+tree
+c_objc_common_truthvalue_conversion (tree expr)
+{
+  expr = default_function_array_conversion (expr);
+  switch (TREE_CODE (TREE_TYPE (expr)))
+    {
+    case ARRAY_TYPE:
+      error ("used array that cannot be converted to pointer where scalar is required");
+      return error_mark_node;
+
+    case RECORD_TYPE:
+      error ("used struct type value where scalar is required");
+      return error_mark_node;
+
+    case UNION_TYPE:
+      error ("used union type value where scalar is required");
+      return error_mark_node;
+
+    default:
+      break;
+    }
+
+  /* ??? Should we also give an error for void and vectors rather than
+     leaving those to give errors later?  */
+  return c_common_truthvalue_conversion (expr);
+}
diff -rupN GCC.orig/gcc/objc/objc-act.c GCC/gcc/objc/objc-act.c
--- GCC.orig/gcc/objc/objc-act.c	2005-01-29 16:07:29.000000000 +0000
+++ GCC/gcc/objc/objc-act.c	2005-03-21 22:07:25.000000000 +0000
@@ -3019,7 +3019,7 @@ next_sjlj_build_enter_and_setjmp (void)
   sj = build_function_call (objc_setjmp_decl, t);
 
   cond = build (COMPOUND_EXPR, TREE_TYPE (sj), enter, sj);
-  cond = lang_hooks.truthvalue_conversion (cond);
+  cond = c_common_truthvalue_conversion (cond);
 
   return build (COND_EXPR, void_type_node, cond, NULL, NULL);
 }
@@ -3086,7 +3086,7 @@ next_sjlj_build_catch_list (void)
 	      t = objc_get_class_reference (OBJC_TYPE_NAME (TREE_TYPE (type)));
 	      args = tree_cons (NULL, t, args);
 	      t = build_function_call (objc_exception_match_decl, args);
-	      cond = lang_hooks.truthvalue_conversion (t);
+	      cond = c_common_truthvalue_conversion (t);
 	    }
 	  t = build (COND_EXPR, void_type_node, cond, body, NULL);
 	  SET_EXPR_LOCUS (t, EXPR_LOCUS (stmt));
@@ -3208,7 +3208,7 @@ next_sjlj_build_try_catch_finally (void)
   /* Build the complete FINALLY statement list.  */
   t = next_sjlj_build_try_exit ();
   t = build_stmt (COND_EXPR,
-		  lang_hooks.truthvalue_conversion (rethrow_decl),
+		  c_common_truthvalue_conversion (rethrow_decl),
 		  NULL, t);
   SET_EXPR_LOCATION (t, cur_try_context->finally_locus);
   append_to_statement_list (t, &TREE_OPERAND (try_fin, 1));
@@ -3219,7 +3219,7 @@ next_sjlj_build_try_catch_finally (void)
   t = tree_cons (NULL, rethrow_decl, NULL);
   t = build_function_call (objc_exception_throw_decl, t);
   t = build_stmt (COND_EXPR,
-		  lang_hooks.truthvalue_conversion (rethrow_decl),
+		  c_common_truthvalue_conversion (rethrow_decl),
 		  t, NULL);
   SET_EXPR_LOCATION (t, cur_try_context->end_finally_locus);
   append_to_statement_list (t, &TREE_OPERAND (try_fin, 1));

2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* langhooks.h (truthvalue_conversion): Remove.
	* langhooks-def.h (LANG_HOOKS_INITIALIZER): Remove
	LANG_HOOKS_TRUTHVALUE_CONVERSION.
	* gimplify.c (gimple_boolify): Don't use truthvalue_conversion.
	* c-objc-common.h (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.

ada:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* misc.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.

cp:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* cp-objcp-common.h (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.

fortran:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* f95-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.

java:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Remove.

treelang:
2005-03-23  Joseph S. Myers  <joseph@codesourcery.com>

	* treetree.c (LANG_HOOKS_TRUTHVALUE_CONVERSION,
	tree_lang_truthvalue_conversion): Remove.
	* tree-convert.c: Don't call truthvalue_conversion.

diff -rupN GCC/gcc/ada/misc.c GCC.new/gcc/ada/misc.c
--- GCC/gcc/ada/misc.c	2005-03-18 20:40:02.000000000 +0000
+++ GCC.new/gcc/ada/misc.c	2005-03-22 00:54:04.000000000 +0000
@@ -137,8 +137,6 @@ static tree gnat_type_max_size		(tree);
 #define LANG_HOOKS_EXPAND_EXPR		gnat_expand_expr
 #undef  LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE	gnat_mark_addressable
-#undef  LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION gnat_truthvalue_conversion
 #undef  LANG_HOOKS_PRINT_DECL
 #define LANG_HOOKS_PRINT_DECL		gnat_print_decl
 #undef  LANG_HOOKS_PRINT_TYPE
diff -rupN GCC/gcc/c-objc-common.h GCC.new/gcc/c-objc-common.h
--- GCC/gcc/c-objc-common.h	2005-03-21 22:06:24.000000000 +0000
+++ GCC.new/gcc/c-objc-common.h	2005-03-22 00:53:45.000000000 +0000
@@ -52,8 +52,6 @@ extern void c_initialize_diagnostics (di
 #define LANG_HOOKS_MARK_ADDRESSABLE c_mark_addressable
 #undef LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
 #undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
diff -rupN GCC/gcc/cp/cp-objcp-common.h GCC.new/gcc/cp/cp-objcp-common.h
--- GCC/gcc/cp/cp-objcp-common.h	2005-02-23 23:43:37.000000000 +0000
+++ GCC.new/gcc/cp/cp-objcp-common.h	2005-03-22 00:47:09.000000000 +0000
@@ -71,8 +71,6 @@ extern tree objcp_tsubst_copy_and_build 
 #define LANG_HOOKS_PARSE_FILE c_common_parse_file
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL cxx_dup_lang_specific_decl
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
 #undef LANG_HOOKS_SET_DECL_ASSEMBLER_NAME
 #define LANG_HOOKS_SET_DECL_ASSEMBLER_NAME mangle_decl
 #undef LANG_HOOKS_MARK_ADDRESSABLE
diff -rupN GCC/gcc/fortran/f95-lang.c GCC.new/gcc/fortran/f95-lang.c
--- GCC/gcc/fortran/f95-lang.c	2005-02-10 14:54:31.000000000 +0000
+++ GCC.new/gcc/fortran/f95-lang.c	2005-03-22 00:47:31.000000000 +0000
@@ -114,7 +114,6 @@ static void gfc_expand_function (tree);
 #undef LANG_HOOKS_POST_OPTIONS
 #undef LANG_HOOKS_PRINT_IDENTIFIER
 #undef LANG_HOOKS_PARSE_FILE
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #undef LANG_HOOKS_TYPE_FOR_MODE
 #undef LANG_HOOKS_TYPE_FOR_SIZE
@@ -133,7 +132,6 @@ static void gfc_expand_function (tree);
 #define LANG_HOOKS_POST_OPTIONS		gfc_post_options
 #define LANG_HOOKS_PRINT_IDENTIFIER     gfc_print_identifier
 #define LANG_HOOKS_PARSE_FILE           gfc_be_parse_file
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION   gfc_truthvalue_conversion
 #define LANG_HOOKS_MARK_ADDRESSABLE        gfc_mark_addressable
 #define LANG_HOOKS_TYPE_FOR_MODE           gfc_type_for_mode
 #define LANG_HOOKS_TYPE_FOR_SIZE           gfc_type_for_size
diff -rupN GCC/gcc/gimplify.c GCC.new/gcc/gimplify.c
--- GCC/gcc/gimplify.c	2005-03-21 17:55:03.000000000 +0000
+++ GCC.new/gcc/gimplify.c	2005-03-22 00:46:57.000000000 +0000
@@ -2073,10 +2073,6 @@ gimple_boolify (tree expr)
   if (TREE_CODE (type) == BOOLEAN_TYPE)
     return expr;
 
-  /* If this is the predicate of a COND_EXPR, it might not even be a
-     truthvalue yet.  */
-  expr = lang_hooks.truthvalue_conversion (expr);
-
   switch (TREE_CODE (expr))
     {
     case TRUTH_AND_EXPR:
diff -rupN GCC/gcc/java/lang.c GCC.new/gcc/java/lang.c
--- GCC/gcc/java/lang.c	2005-03-08 13:32:36.000000000 +0000
+++ GCC.new/gcc/java/lang.c	2005-03-22 00:47:39.000000000 +0000
@@ -172,8 +172,6 @@ struct language_function GTY(())
 #define LANG_HOOKS_PARSE_FILE java_parse_file
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE java_mark_addressable
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION java_truthvalue_conversion
 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL java_dup_lang_specific_decl
 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
diff -rupN GCC/gcc/langhooks-def.h GCC.new/gcc/langhooks-def.h
--- GCC/gcc/langhooks-def.h	2005-02-23 23:43:22.000000000 +0000
+++ GCC.new/gcc/langhooks-def.h	2005-03-22 00:46:24.000000000 +0000
@@ -267,7 +267,6 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_EXPAND_CONSTANT, \
   LANG_HOOKS_EXPAND_EXPR, \
   LANG_HOOKS_EXPAND_DECL, \
-  LANG_HOOKS_TRUTHVALUE_CONVERSION, \
   LANG_HOOKS_SAFE_FROM_P, \
   LANG_HOOKS_FINISH_INCOMPLETE_DECL, \
   LANG_HOOKS_MARK_ADDRESSABLE, \
diff -rupN GCC/gcc/langhooks.h GCC.new/gcc/langhooks.h
--- GCC/gcc/langhooks.h	2005-02-23 23:43:22.000000000 +0000
+++ GCC.new/gcc/langhooks.h	2005-03-22 00:46:45.000000000 +0000
@@ -277,19 +277,6 @@ struct lang_hooks
      1 if handled, 0 otherwise.  */
   int (*expand_decl) (tree);
 
-  /* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
-     operation.
-
-     This preparation consists of taking the ordinary representation
-     of an expression expr and producing a valid tree boolean
-     expression describing whether expr is nonzero.  We could simply
-     always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
-     but we optimize comparisons, &&, ||, and !.
-
-     The result should be an expression of boolean type (if not an
-     error_mark_node).  */
-  tree (*truthvalue_conversion) (tree);
-
   /* Hook called by safe_from_p for language-specific tree codes.  It is
      up to the language front-end to install a hook if it has any such
      codes that safe_from_p needs to know about.  Since same_from_p will
diff -rupN GCC/gcc/treelang/tree-convert.c GCC.new/gcc/treelang/tree-convert.c
--- GCC/gcc/treelang/tree-convert.c	2003-07-28 04:39:29.000000000 +0000
+++ GCC.new/gcc/treelang/tree-convert.c	2005-03-22 00:48:21.000000000 +0000
@@ -85,7 +85,7 @@ convert (tree type, tree expr)
     return fold (convert_to_integer (type, e));
   if (code == BOOLEAN_TYPE)
     {
-      tree t = (*lang_hooks.truthvalue_conversion) (expr);
+      tree t = expr;
       /* If it returns a NOP_EXPR, we must fold it here to avoid
 	 infinite recursion between fold () and convert ().  */
       if (TREE_CODE (t) == NOP_EXPR)
diff -rupN GCC/gcc/treelang/treetree.c GCC.new/gcc/treelang/treetree.c
--- GCC/gcc/treelang/treetree.c	2005-02-28 19:19:41.000000000 +0000
+++ GCC.new/gcc/treelang/treetree.c	2005-03-22 00:48:07.000000000 +0000
@@ -124,7 +124,6 @@ struct language_function GTY(())
   char junk; /* dummy field to ensure struct is not empty */
 };
 
-static tree tree_lang_truthvalue_conversion (tree expr);
 static bool tree_mark_addressable (tree exp);
 static tree tree_lang_type_for_size (unsigned precision, int unsignedp);
 static tree tree_lang_type_for_mode (enum machine_mode mode, int unsignedp);
@@ -153,8 +152,6 @@ static void treelang_expand_function (tr
    end).  These are not really very language-dependent, i.e.
    treelang, C, Mercury, etc. can all use almost the same definitions.  */
 
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION tree_lang_truthvalue_conversion
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE tree_mark_addressable
 #undef LANG_HOOKS_SIGNED_TYPE
@@ -781,13 +778,6 @@ dt (tree t)
    allocate each of them once. Signed and unsigned types are kept separate.  */
 static GTY(()) tree signed_and_unsigned_types[MAX_BITS_PER_WORD + 1][2];
 
-/* XXX is this definition OK? */
-static tree
-tree_lang_truthvalue_conversion (tree expr)
-{
-  return expr;
-}
-
 /* Mark EXP saying that we need to be able to take the
    address of it; it should not be allocated in a register.
    Value is 1 if successful.  



More information about the Gcc-patches mailing list