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]

Re: [PATCH] Fix PR c/11658


All your comments are addressed in this patch and in the attached testcases.

Ok for mainline?

Paolo
2004-02-02  Paolo Bonzini  <bonzini@gnu.org>

	PR c/11658
	* Makefile.in (c-parse.o, c-convert.o, c-typeck.o): Depend
	on langhooks.h.
	* objc/Make-lang.in (objc-parse.o): Depend on langhooks.h.
	* c-parse.in, c-convert.c, c-typeck.c, objc/objc-act.c:
	Include langhooks.h.  Replace c_common_truthvalue_conversion
	with the truthvalue_conversion language hook throughout.
	* c-common.c (c_common_truthvalue_conversion): Remove
	obsolete block.  Invoke recursively the hook instead
	of this function.
	* c-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Use
	c_objc_common_truthvalue_conversion.
	* c-objc-common.c (c_objc_common_truthvalue_conversion):
	New function.
	* c-tree.h (c_objc_common_truthvalue_conversion): Declare it.
	* objc/objc-lang.c (LANG_HOOKS_TRUTHVALUE_CONVERSION): Use
	c_objc_common_truthvalue_conversion.

	* testsuite/gcc.dg/noncompile/20040202-1.c,
	testsuite/gcc.dg/noncompile/20040202-2.c,
	testsuite/gcc.dg/noncompile/20040202-3.c,
	testsuite/gcc.dg/noncompile/20040202-4.c: New testcases.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.479
diff -u -p -r1.479 c-common.c
--- c-common.c	21 Jan 2004 20:39:51 -0000	1.479
+++ c-common.c	2 Feb 2004 15:55:49 -0000
@@ -2614,28 +2614,6 @@ c_common_truthvalue_conversion (tree exp
   if (TREE_CODE (expr) == FUNCTION_DECL)
     expr = build_unary_op (ADDR_EXPR, expr, 0);
 
-#if 0 /* This appears to be wrong for C++.  */
-  /* These really should return error_mark_node after 2.4 is stable.
-     But not all callers handle ERROR_MARK properly.  */
-  switch (TREE_CODE (TREE_TYPE (expr)))
-    {
-    case RECORD_TYPE:
-      error ("struct type value used where scalar is required");
-      return truthvalue_false_node;
-
-    case UNION_TYPE:
-      error ("union type value used where scalar is required");
-      return truthvalue_false_node;
-
-    case ARRAY_TYPE:
-      error ("array type value used where scalar is required");
-      return truthvalue_false_node;
-
-    default:
-      break;
-    }
-#endif /* 0 */
-
   switch (TREE_CODE (expr))
     {
     case EQ_EXPR:
@@ -2686,15 +2664,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),
-		c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)),
-		c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
+		(*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0)),
+		(*lang_hooks.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 c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
+      return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
 
     case LROTATE_EXPR:
     case RROTATE_EXPR:
@@ -2702,15 +2680,15 @@ c_common_truthvalue_conversion (tree exp
 	 we can't ignore them if their second arg has side-effects.  */
       if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
 	return build (COMPOUND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 1),
-		      c_common_truthvalue_conversion (TREE_OPERAND (expr, 0)));
+		      (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0)));
       else
-	return c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
+	return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
 
     case COND_EXPR:
       /* Distribute the conversion into the arms of a COND_EXPR.  */
       return fold (build (COND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 0),
-		c_common_truthvalue_conversion (TREE_OPERAND (expr, 1)),
-		c_common_truthvalue_conversion (TREE_OPERAND (expr, 2))));
+		(*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 1)),
+		(*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 2))));
 
     case CONVERT_EXPR:
       /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
@@ -2723,7 +2701,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 c_common_truthvalue_conversion (TREE_OPERAND (expr, 0));
+	return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
       break;
 
     case MINUS_EXPR:
@@ -2772,8 +2750,8 @@ c_common_truthvalue_conversion (tree exp
       return (build_binary_op
 	      ((TREE_SIDE_EFFECTS (expr)
 		? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
-	c_common_truthvalue_conversion (build_unary_op (REALPART_EXPR, t, 0)),
-	c_common_truthvalue_conversion (build_unary_op (IMAGPART_EXPR, t, 0)),
+	(*lang_hooks.truthvalue_conversion) (build_unary_op (REALPART_EXPR, t, 0)),
+	(*lang_hooks.truthvalue_conversion) (build_unary_op (IMAGPART_EXPR, t, 0)),
 	       0));
     }
 
Index: c-convert.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-convert.c,v
retrieving revision 1.18
diff -u -p -r1.18 c-convert.c
--- c-convert.c	19 Jun 2003 19:43:58 -0000	1.18
+++ c-convert.c	2 Feb 2004 15:55:49 -0000
@@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - S
 #include "flags.h"
 #include "convert.h"
 #include "c-common.h"
+#include "langhooks.h"
 #include "toplev.h"
 
 /* Change of width--truncation and extension of integers or reals--
@@ -94,7 +95,10 @@ convert (tree type, tree expr)
     return fold (convert_to_integer (type, e));
   if (code == BOOLEAN_TYPE)
     {
-      tree t = c_common_truthvalue_conversion (expr);
+      tree t = (*lang_hooks.truthvalue_conversion) (expr);
+      if (TREE_CODE (t) == ERROR_MARK)
+	return t;
+
       /* 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)
Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.119
diff -u -p -r1.119 c-lang.c
--- c-lang.c	25 Sep 2003 01:25:46 -0000	1.119
+++ c-lang.c	2 Feb 2004 15:55:49 -0000
@@ -66,7 +66,7 @@ enum c_language_kind c_language = clk_c;
 #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
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_objc_common_truthvalue_conversion
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
 #undef LANG_HOOKS_UNSAFE_FOR_REEVAL
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.37
diff -u -p -r1.37 c-objc-common.c
--- c-objc-common.c	1 Jan 2004 13:58:56 -0000	1.37
+++ c-objc-common.c	2 Feb 2004 15:55:49 -0000
@@ -332,3 +332,32 @@ c_tree_printer (pretty_printer *pp, text
   pp_string (pp, n);
   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 ("struct type value used where scalar is required");
+      return error_mark_node;
+
+    case UNION_TYPE:
+      error ("union type value used where scalar is required");
+      return error_mark_node;
+    default:
+      break;
+    }
+
+  return c_common_truthvalue_conversion (expr);
+}
+
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.196
diff -u -p -r1.196 c-parse.in
--- c-parse.in	26 Jan 2004 23:02:04 -0000	1.196
+++ c-parse.in	2 Feb 2004 15:55:49 -0000
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - S
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "langhooks.h"
 #include "input.h"
 #include "cpplib.h"
 #include "intl.h"
@@ -579,21 +580,21 @@ expr_no_commas:
 	| expr_no_commas '^' expr_no_commas
 		{ $$ = parser_build_binary_op ($2, $1, $3); }
 	| expr_no_commas ANDAND
-		{ $1 = c_common_truthvalue_conversion
+		{ $1 = (*lang_hooks.truthvalue_conversion)
 		    (default_conversion ($1));
 		  skip_evaluation += $1 == truthvalue_false_node; }
 	  expr_no_commas
 		{ skip_evaluation -= $1 == truthvalue_false_node;
 		  $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); }
 	| expr_no_commas OROR
-		{ $1 = c_common_truthvalue_conversion
+		{ $1 = (*lang_hooks.truthvalue_conversion)
 		    (default_conversion ($1));
 		  skip_evaluation += $1 == truthvalue_true_node; }
 	  expr_no_commas
 		{ skip_evaluation -= $1 == truthvalue_true_node;
 		  $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); }
 	| expr_no_commas '?'
-		{ $1 = c_common_truthvalue_conversion
+		{ $1 = (*lang_hooks.truthvalue_conversion)
 		    (default_conversion ($1));
 		  skip_evaluation += $1 == truthvalue_false_node; }
           expr ':'
@@ -607,7 +608,7 @@ expr_no_commas:
 		    pedwarn ("ISO C forbids omitting the middle term of a ?: expression");
 		  /* Make sure first operand is calculated only once.  */
 		  $<ttype>2 = save_expr ($1);
-		  $1 = c_common_truthvalue_conversion
+		  $1 = (*lang_hooks.truthvalue_conversion)
 		    (default_conversion ($<ttype>2));
 		  skip_evaluation += $1 == truthvalue_true_node; }
 	  ':' expr_no_commas
@@ -2192,7 +2193,7 @@ if_prefix:
           IF
                 { $<ttype>$ = c_begin_if_stmt (); }
             '(' expr ')'
-		{ c_expand_start_cond (c_common_truthvalue_conversion ($4),
+		{ c_expand_start_cond ((*lang_hooks.truthvalue_conversion) ($4),
 				       compstmt_count,$<ttype>2);
 		  $<itype>$ = stmt_count;
 		  if_stmt_locus = $<location>-1; }
@@ -2301,16 +2302,16 @@ select_or_iter_stmt:
 		  $<ttype>$ = c_begin_while_stmt (); }
 	  '(' expr ')'
                 { c_in_iteration_stmt++;
-		  $4 = c_common_truthvalue_conversion ($4);
+		  $4 = (*lang_hooks.truthvalue_conversion) ($4);
 		  c_finish_while_stmt_cond
-		    (c_common_truthvalue_conversion ($4), $<ttype>2);
+		    ((*lang_hooks.truthvalue_conversion) ($4), $<ttype>2);
 		  $<ttype>$ = add_stmt ($<ttype>2); }
 	  c99_block_lineno_labeled_stmt
                 { c_in_iteration_stmt--;
 		  RECHAIN_STMTS ($<ttype>6, WHILE_BODY ($<ttype>6)); }
 	| do_stmt_start
 	  '(' expr ')' ';'
-                { DO_COND ($1) = c_common_truthvalue_conversion ($3); }
+                { DO_COND ($1) = (*lang_hooks.truthvalue_conversion) ($3); }
 	| do_stmt_start error
 		{ }
 	| FOR
@@ -2323,7 +2324,7 @@ select_or_iter_stmt:
 	  xexpr ';'
                 { if ($6)
 		    FOR_COND ($<ttype>2)
-		      = c_common_truthvalue_conversion ($6); }
+		      = (*lang_hooks.truthvalue_conversion) ($6); }
 	  xexpr ')'
                 { c_in_iteration_stmt++;
 		  FOR_EXPR ($<ttype>2) = $9; }
Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.136
diff -u -p -r1.136 c-tree.h
--- c-tree.h	3 Dec 2003 23:33:48 -0000	1.136
+++ c-tree.h	2 Feb 2004 15:55:50 -0000
@@ -237,6 +237,7 @@ extern void merge_translation_unit_decls
 extern int c_disregard_inline_limits (tree);
 extern int c_cannot_inline_tree_fn (tree *);
 extern bool c_objc_common_init (void);
+extern tree c_objc_common_truthvalue_conversion (tree expr);
 extern int c_missing_noreturn_ok_p (tree);
 extern void c_objc_common_finish_file (void);
 extern int defer_fn (tree);
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.274
diff -u -p -r1.274 c-typeck.c
--- c-typeck.c	24 Jan 2004 00:30:55 -0000	1.274
+++ c-typeck.c	2 Feb 2004 15:55:51 -0000
@@ -35,6 +35,7 @@ Software Foundation, 59 Temple Place - S
 #include "tm.h"
 #include "rtl.h"
 #include "tree.h"
+#include "langhooks.h"
 #include "c-tree.h"
 #include "tm_p.h"
 #include "flags.h"
@@ -2259,7 +2260,7 @@ build_unary_op (enum tree_code code, tre
 	  error ("wrong type argument to unary exclamation mark");
 	  return error_mark_node;
 	}
-      arg = c_common_truthvalue_conversion (arg);
+      arg = (*lang_hooks.truthvalue_conversion) (arg);
       return invert_truthvalue (arg);
 
     case NOP_EXPR:
@@ -2632,7 +2633,7 @@ build_conditional_expr (tree ifexp, tree
   tree result_type = NULL;
   tree orig_op1 = op1, orig_op2 = op2;
 
-  ifexp = c_common_truthvalue_conversion (default_conversion (ifexp));
+  ifexp = (*lang_hooks.truthvalue_conversion) (default_conversion (ifexp));
 
   /* Promote both alternatives.  */
 
@@ -6539,8 +6540,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 = c_common_truthvalue_conversion (op0);
-	  op1 = c_common_truthvalue_conversion (op1);
+	  op0 = (*lang_hooks.truthvalue_conversion) (op0);
+	  op1 = (*lang_hooks.truthvalue_conversion) (op1);
 	  converted = 1;
 	}
       break;
@@ -6777,6 +6778,9 @@ build_binary_op (enum tree_code code, tr
     default:
       break;
     }
+
+  if (code0 == ERROR_MARK || code1 == ERROR_MARK)
+    return error_mark_node;
 
   if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
        || code0 == VECTOR_TYPE)
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1240
diff -u -p -r1.1240 Makefile.in
--- Makefile.in	2 Feb 2004 00:17:08 -0000	1.1240
+++ Makefile.in	2 Feb 2004 15:55:51 -0000
@@ -1272,7 +1272,7 @@ c-errors.o: c-errors.c $(CONFIG_H) $(SYS
     $(C_TREE_H) flags.h $(DIAGNOSTIC_H) $(TM_P_H)
 c-parse.o : c-parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(GGC_H) intl.h $(C_TREE_H) input.h flags.h toplev.h output.h $(CPPLIB_H) \
-    varray.h gt-c-parse.h
+    varray.h gt-c-parse.h langhooks.h
 
 srcextra: c-parse.y c-parse.c gengtype-lex.c gengtype-yacc.c gengtype-yacc.h
 	-cp -p $^ $(srcdir)
@@ -1295,7 +1295,8 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM
     opts.h c-pragma.h gt-c-decl.h cgraph.h $(HASHTAB_H) libfuncs.h except.h \
     $(LANGHOOKS_DEF_H)
 c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
-    $(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H)
+    $(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H) \
+    langhooks.h
 c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
     $(C_TREE_H) $(C_PRETTY_PRINT_H) $(DIAGNOSTIC_H) \
     $(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-c.h
@@ -1345,7 +1346,7 @@ c-common.o : c-common.c $(CONFIG_H) $(SY
 	$(OBSTACK_H) $(C_COMMON_H) flags.h toplev.h output.h c-pragma.h intl.h \
 	$(GGC_H) $(EXPR_H) $(TM_P_H) builtin-types.def builtin-attrs.def \
 	$(DIAGNOSTIC_H) gt-c-common.h langhooks.h varray.h $(RTL_H) \
-	$(TARGET_H) $(C_TREE_H)
+	$(TARGET_H) $(C_TREE_H) langhooks.h
 c-pretty-print.o : c-pretty-print.c $(C_PRETTY_PRINT_H) \
 	$(C_COMMON_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) real.h
 
Index: objc/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/Make-lang.in,v
retrieving revision 1.69
diff -u -p -r1.69 Make-lang.in
--- objc/Make-lang.in	21 Jan 2004 02:01:55 -0000	1.69
+++ objc/Make-lang.in	2 Feb 2004 16:03:29 -0000
@@ -64,7 +64,8 @@ objc/objc-lang.o : objc/objc-lang.c \
 
 objc/objc-parse.o : objc/objc-parse.c \
    $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
-   toplev.h $(GGC_H) c-pragma.h input.h flags.h output.h objc/objc-act.h
+   toplev.h $(GGC_H) c-pragma.h input.h flags.h output.h objc/objc-act.h \
+   langhooks.h
 
 objc/objc-act.o : objc/objc-act.c \
    $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) $(TM_P_H) \
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.203
diff -u -p -r1.203 objc-act.c
--- objc/objc-act.c	18 Jan 2004 01:15:28 -0000	1.203
+++ objc/objc-act.c	2 Feb 2004 16:03:31 -0000
@@ -50,6 +50,7 @@ Boston, MA 02111-1307, USA.  */
 #include "c-tree.h"
 #include "c-common.h"
 #include "flags.h"
+#include "langhooks.h"
 #include "objc-act.h"
 #include "input.h"
 #include "except.h"
@@ -2850,7 +2851,7 @@ objc_build_try_enter_fragment (void)
   cond = build_unary_op (TRUTH_NOT_EXPR,
 			 build_function_call (objc_setjmp_decl, func_params),
 			 0);
-  c_expand_start_cond (c_common_truthvalue_conversion (cond),
+  c_expand_start_cond ((*lang_hooks.truthvalue_conversion) (cond),
 		       0, if_stmt);
   objc_enter_block ();
 }
@@ -2978,7 +2979,7 @@ objc_build_try_epilogue (int also_catch_
       val_stack_push (&catch_count_stack, 1);
       if_stmt = c_begin_if_stmt ();
       if_nesting_count++;
-      c_expand_start_cond (c_common_truthvalue_conversion (boolean_false_node),
+      c_expand_start_cond ((*lang_hooks.truthvalue_conversion) (boolean_false_node),
 			   0, if_stmt);
       objc_enter_block ();
 
@@ -3068,7 +3069,7 @@ objc_build_catch_stmt (tree catch_expr)
       cond = build_function_call (objc_exception_match_decl, func_params);
     }
 
-  c_expand_start_cond (c_common_truthvalue_conversion (cond),
+  c_expand_start_cond ((*lang_hooks.truthvalue_conversion) (cond),
 		       0, if_stmt);
   objc_enter_block ();
   objc_declare_variable (RID_REGISTER, var_name,
@@ -3138,7 +3139,7 @@ objc_build_finally_prologue (void)
   tree if_stmt = c_begin_if_stmt ();
   if_nesting_count++;
 
-  c_expand_start_cond (c_common_truthvalue_conversion
+  c_expand_start_cond ((*lang_hooks.truthvalue_conversion)
 		       (build_unary_op
 		        (TRUTH_NOT_EXPR,
 			 TREE_VALUE (objc_rethrow_exception), 0)),
@@ -3166,7 +3167,7 @@ objc_build_finally_epilogue (void)
   if_nesting_count++;
 
   c_expand_start_cond
-    (c_common_truthvalue_conversion (TREE_VALUE (objc_rethrow_exception)),
+    ((*lang_hooks.truthvalue_conversion) (TREE_VALUE (objc_rethrow_exception)),
      0, if_stmt);
   objc_enter_block ();
   objc_build_throw_stmt (TREE_VALUE (objc_rethrow_exception));
Index: objc/objc-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-lang.c,v
retrieving revision 1.39
diff -u -p -r1.39 objc-lang.c
--- objc/objc-lang.c	29 Aug 2003 23:21:13 -0000	1.39
+++ objc/objc-lang.c	2 Feb 2004 16:03:31 -0000
@@ -60,7 +60,7 @@ enum c_language_kind c_language = clk_ob
 #undef LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE c_mark_addressable
 #undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_common_truthvalue_conversion
+#define LANG_HOOKS_TRUTHVALUE_CONVERSION c_objc_common_truthvalue_conversion
 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL c_finish_incomplete_decl
 #undef LANG_HOOKS_UNSAFE_FOR_REEVAL
struct a {
};

int bug_if(struct a a) { if (a) return 1; else return 0; }  /* { dg-error "struct type" } */
int bug_while(struct a a) { while (a); }  /* { dg-error "struct type" } */
int bug_do_while(struct a a) { do ; while (a); }  /* { dg-error "struct type" } */
int bug_for(struct a a) { for ( ; a; ) ; }  /* { dg-error "struct type" } */
int bug_or(struct a a) { return (a || 1); }  /* { dg-error "struct type" } */
int bug_and(struct a a) { return (a && 1); }  /* { dg-error "struct type" } */
int bug_cond(struct a a) { return (a ? 1 : 0); }  /* { dg-error "struct type" } */
int bug_cond2(struct a a) { return (a ? : 0); }  /* { dg-error "struct type" } */
int bug_bool(struct a a) { return (_Bool) a; }  /* { dg-error "struct type" } */
struct s { char c[1]; };
struct s f(void);

int bug_if(void) { if (f().c) return 1; else return 0; }  /* { dg-error "array that cannot be converted" } */
int bug_while(void) { while (f().c); }  /* { dg-error "array that cannot be converted" } */
int bug_do_while(void) { do ; while (f().c); }  /* { dg-error "array that cannot be converted" } */
int bug_for(void) { for ( ; f().c; ) ; }  /* { dg-error "array that cannot be converted" } */
int bug_or(void) { return (f().c || 1); }  /* { dg-error "array that cannot be converted" } */
int bug_and(void) { return (f().c && 1); }  /* { dg-error "array that cannot be converted" } */
int bug_cond(void) { return (f().c ? 1 : 0); }  /* { dg-error "array that cannot be converted" } */
int bug_cond2(void) { return (f().c ? : 0); }  /* { dg-error "array that cannot be converted" } */
int bug_not(void) { return !f().c; }  /* { dg-error "array that cannot be converted" } */
int bug_bool(void) { return (_Bool) f().c; }  /* { dg-error "array that cannot be converted" } */
struct s { char c[1]; };
struct s a;

int bug_if(void) { if (a.c) return 1; else return 0; }
int bug_while(void) { while (a.c); }
int bug_do_while(void) { do ; while (a.c); }
int bug_for(void) { for ( ; a.c; ) ; }
int bug_or(void) { return (a.c || 1); }
int bug_and(void) { return (a.c && 1); }
int bug_cond(void) { return (a.c ? 1 : 0); }
int bug_cond2(void) { return (a.c ? : 0); }  /* { dg-error "array that cannot be converted" } */
int bug_not(void) { return !a.c; }
int bug_bool(void) { return (_Bool) a.c; }
union a {
};

int bug_if(union a a) { if (a) return 1; else return 0; }  /* { dg-error "union type" } */
int bug_while(union a a) { while (a); }  /* { dg-error "union type" } */
int bug_do_while(union a a) { do ; while (a); }  /* { dg-error "union type" } */
int bug_for(union a a) { for ( ; a; ) ; }  /* { dg-error "union type" } */
int bug_or(union a a) { return (a || 1); }  /* { dg-error "union type" } */
int bug_and(union a a) { return (a && 1); }  /* { dg-error "union type" } */
int bug_cond(union a a) { return (a ? 1 : 0); }  /* { dg-error "union type" } */
int bug_cond2(union a a) { return (a ? : 0); }  /* { dg-error "union type" } */
int bug_bool(union a a) { return (_Bool) a; }  /* { dg-error "union type" } */

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