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]

Patch to remove comptypes flags parameter


This patch removes the presently unused flags parameter from the C
front end's comptypes function, as discussed
<http://gcc.gnu.org/ml/gcc/2004-06/msg00377.html>.  Note the lack of
consistency about whether existing uses passed COMPARE_STRICT, 0 or
false (all the same value).

Bootstrapped with no regressions on i686-pc-linux-gnu.  Applied to
mainline.

2004-06-13  Joseph S. Myers  <jsm@polyomino.org.uk>

	* c-typeck.c (comptypes, tagged_types_tu_compatible_p,
	function_types_compatible_p, type_lists_compatible_p): Remove
	flags parameter.
	* c-tree.h (comptypes): Likewise.
	(COMPARE_STRICT): Remove.
	* c-decl.c, c-lang.c, c-parse.in, c-typeck.c, objc/objc-act.c: All
	callers changed.

diff -rupN gcc.orig/c-decl.c gcc/c-decl.c
--- gcc.orig/c-decl.c	2004-06-07 19:41:26.000000000 +0000
+++ gcc/c-decl.c	2004-06-13 09:29:28.000000000 +0000
@@ -936,7 +936,7 @@ diagnose_arglist_conflict (tree newdecl,
   tree t;
 
   if (TREE_CODE (olddecl) != FUNCTION_DECL
-      || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype), COMPARE_STRICT)
+      || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype))
       || !((TYPE_ARG_TYPES (oldtype) == 0 && DECL_INITIAL (olddecl) == 0)
 	   ||
 	   (TYPE_ARG_TYPES (newtype) == 0 && DECL_INITIAL (newdecl) == 0)))
@@ -1008,7 +1008,7 @@ validate_proto_after_old_defn (tree newd
 
       /* Type for passing arg must be consistent with that declared
 	 for the arg.  */
-      else if (! comptypes (oldargtype, newargtype, COMPARE_STRICT))
+      else if (! comptypes (oldargtype, newargtype))
 	{
 	  error ("%Jprototype for '%D' declares arg %d with incompatible type",
 		 newdecl, newdecl, i);
@@ -1090,7 +1090,7 @@ diagnose_mismatched_decls (tree newdecl,
       return false;
     }
 
-  if (!comptypes (oldtype, newtype, COMPARE_STRICT))
+  if (!comptypes (oldtype, newtype))
     {
       if (TREE_CODE (olddecl) == FUNCTION_DECL
 	  && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (olddecl))
@@ -1099,7 +1099,7 @@ diagnose_mismatched_decls (tree newdecl,
 	     This is for the ffs and fprintf builtins.  */
 	  tree trytype = match_builtin_function_types (newtype, oldtype);
 
-	  if (trytype && comptypes (newtype, trytype, COMPARE_STRICT))
+	  if (trytype && comptypes (newtype, trytype))
 	    *oldtypep = oldtype = trytype;
 	  else
 	    {
@@ -6027,8 +6027,7 @@ store_parm_decls_oldstyle (tree fndecl, 
 	     declared for the arg.  ISO C says we take the unqualified
 	     type for parameters declared with qualified type.  */
 	  if (! comptypes (TYPE_MAIN_VARIANT (DECL_ARG_TYPE (parm)),
-			   TYPE_MAIN_VARIANT (TREE_VALUE (type)),
-			   COMPARE_STRICT))
+			   TYPE_MAIN_VARIANT (TREE_VALUE (type))))
 	    {
 	      if (TYPE_MAIN_VARIANT (TREE_TYPE (parm))
 		  == TYPE_MAIN_VARIANT (TREE_VALUE (type)))
diff -rupN gcc.orig/c-lang.c gcc/c-lang.c
--- gcc.orig/c-lang.c	2004-05-14 20:08:29.000000000 +0000
+++ gcc/c-lang.c	2004-06-13 09:28:56.000000000 +0000
@@ -216,7 +216,7 @@ finish_file (void)
 int
 c_types_compatible_p (tree x, tree y)
 {
-    return comptypes (TYPE_MAIN_VARIANT (x), TYPE_MAIN_VARIANT (y), 0);
+    return comptypes (TYPE_MAIN_VARIANT (x), TYPE_MAIN_VARIANT (y));
 }
 static void
 c_initialize_diagnostics (diagnostic_context *context)
diff -rupN gcc.orig/c-parse.in gcc/c-parse.in
--- gcc.orig/c-parse.in	2004-06-07 19:46:33.000000000 +0000
+++ gcc/c-parse.in	2004-06-13 09:28:49.000000000 +0000
@@ -700,7 +700,7 @@ primary:
 		  e1 = TYPE_MAIN_VARIANT (groktypename ($3));
 		  e2 = TYPE_MAIN_VARIANT (groktypename ($5));
 
-		  $$ = comptypes (e1, e2, COMPARE_STRICT)
+		  $$ = comptypes (e1, e2)
 		    ? build_int_2 (1, 0) : build_int_2 (0, 0);
 		}
 	| TYPES_COMPATIBLE_P '(' error ')'
diff -rupN gcc.orig/c-tree.h gcc/c-tree.h
--- gcc.orig/c-tree.h	2004-06-06 15:18:53.000000000 +0000
+++ gcc/c-tree.h	2004-06-13 09:28:33.000000000 +0000
@@ -214,14 +214,9 @@ extern bool c_warn_unused_global_decl (t
 
 /* in c-typeck.c */
 
-/* For use with comptypes.  */
-enum {
-  COMPARE_STRICT = 0
-};
-
 extern tree require_complete_type (tree);
 extern int same_translation_unit_p (tree, tree);
-extern int comptypes (tree, tree, int);
+extern int comptypes (tree, tree);
 extern tree c_size_in_bytes (tree);
 extern bool c_mark_addressable (tree);
 extern void c_incomplete_type_error (tree, tree);
diff -rupN gcc.orig/c-typeck.c gcc/c-typeck.c
--- gcc.orig/c-typeck.c	2004-06-12 08:54:38.000000000 +0000
+++ gcc/c-typeck.c	2004-06-13 09:27:47.000000000 +0000
@@ -54,10 +54,10 @@ static int require_constant_value;
 static int require_constant_elements;
 
 static tree qualify_type (tree, tree);
-static int tagged_types_tu_compatible_p (tree, tree, int);
+static int tagged_types_tu_compatible_p (tree, tree);
 static int comp_target_types (tree, tree, int);
-static int function_types_compatible_p (tree, tree, int);
-static int type_lists_compatible_p (tree, tree, int);
+static int function_types_compatible_p (tree, tree);
+static int type_lists_compatible_p (tree, tree);
 static tree decl_constant_value_for_broken_optimization (tree);
 static tree default_function_array_conversion (tree);
 static tree lookup_field (tree, tree);
@@ -338,8 +338,7 @@ composite_type (tree t1, tree t2)
 		tree memb;
 		for (memb = TYPE_FIELDS (TREE_VALUE (p1));
 		     memb; memb = TREE_CHAIN (memb))
-		  if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2),
-				 COMPARE_STRICT))
+		  if (comptypes (TREE_TYPE (memb), TREE_VALUE (p2)))
 		    {
 		      TREE_VALUE (n) = TREE_VALUE (p2);
 		      if (pedantic)
@@ -353,8 +352,7 @@ composite_type (tree t1, tree t2)
 		tree memb;
 		for (memb = TYPE_FIELDS (TREE_VALUE (p2));
 		     memb; memb = TREE_CHAIN (memb))
-		  if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1),
-				 COMPARE_STRICT))
+		  if (comptypes (TREE_TYPE (memb), TREE_VALUE (p1)))
 		    {
 		      TREE_VALUE (n) = TREE_VALUE (p1);
 		      if (pedantic)
@@ -558,7 +556,7 @@ common_type (tree t1, tree t2)
    but a warning may be needed if you use them together.  */
 
 int
-comptypes (tree type1, tree type2, int flags)
+comptypes (tree type1, tree type2)
 {
   tree t1 = type1;
   tree t2 = type2;
@@ -625,11 +623,11 @@ comptypes (tree type1, tree type2, int f
       if (c_dialect_objc () && (val = objc_comptypes (t1, t2, 0)) >= 0)
 	break;
       val = (TREE_TYPE (t1) == TREE_TYPE (t2)
-	     ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2), flags));
+	     ? 1 : comptypes (TREE_TYPE (t1), TREE_TYPE (t2)));
       break;
 
     case FUNCTION_TYPE:
-      val = function_types_compatible_p (t1, t2, flags);
+      val = function_types_compatible_p (t1, t2);
       break;
 
     case ARRAY_TYPE:
@@ -642,8 +640,7 @@ comptypes (tree type1, tree type2, int f
 
 	/* Target types must match incl. qualifiers.  */
 	if (TREE_TYPE (t1) != TREE_TYPE (t2)
-	    && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2),
-				      flags)))
+	    && 0 == (val = comptypes (TREE_TYPE (t1), TREE_TYPE (t2))))
 	  return 0;
 
 	/* Sizes must match unless one is missing or variable.  */
@@ -681,12 +678,12 @@ comptypes (tree type1, tree type2, int f
     case ENUMERAL_TYPE:
     case UNION_TYPE:
       if (val != 1 && !same_translation_unit_p (t1, t2))
-	val = tagged_types_tu_compatible_p (t1, t2, flags);
+	val = tagged_types_tu_compatible_p (t1, t2);
       break;
 
     case VECTOR_TYPE:
       val = TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
-	    && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), 0);
+	    && comptypes (TREE_TYPE (t1), TREE_TYPE (t2));
       break;
 
     default:
@@ -712,7 +709,7 @@ comp_target_types (tree ttl, tree ttr, i
     return val;
 
   val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
-		   TYPE_MAIN_VARIANT (TREE_TYPE (ttr)), COMPARE_STRICT);
+		   TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
 
   if (val == 2 && pedantic)
     pedwarn ("types are not quite compatible");
@@ -772,7 +769,7 @@ static const struct tagged_tu_seen * tag
    rules.  */
 
 static int
-tagged_types_tu_compatible_p (tree t1, tree t2, int flags)
+tagged_types_tu_compatible_p (tree t1, tree t2)
 {
   tree s1, s2;
   bool needs_warning = false;
@@ -869,7 +866,7 @@ tagged_types_tu_compatible_p (tree t1, t
 		if (DECL_NAME (s1) == DECL_NAME (s2))
 		  {
 		    int result;
-		    result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2), flags);
+		    result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2));
 		    if (result == 0)
 		      break;
 		    if (result == 2)
@@ -907,7 +904,7 @@ tagged_types_tu_compatible_p (tree t1, t
 	    if (TREE_CODE (s1) != TREE_CODE (s2)
 		|| DECL_NAME (s1) != DECL_NAME (s2))
 	      break;
-	    result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2), flags);
+	    result = comptypes (TREE_TYPE (s1), TREE_TYPE (s2));
 	    if (result == 0)
 	      break;
 	    if (result == 2)
@@ -937,7 +934,7 @@ tagged_types_tu_compatible_p (tree t1, t
    Otherwise, the argument types must match.  */
 
 static int
-function_types_compatible_p (tree f1, tree f2, int flags)
+function_types_compatible_p (tree f1, tree f2)
 {
   tree args1, args2;
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
@@ -958,7 +955,7 @@ function_types_compatible_p (tree f1, tr
   if (TYPE_VOLATILE (ret2))
     ret2 = build_qualified_type (TYPE_MAIN_VARIANT (ret2),
 				 TYPE_QUALS (ret2) & ~TYPE_QUAL_VOLATILE);
-  val = comptypes (ret1, ret2, flags);
+  val = comptypes (ret1, ret2);
   if (val == 0)
     return 0;
 
@@ -976,8 +973,7 @@ function_types_compatible_p (tree f1, tr
 	 compare that with the other type's arglist.
 	 If they don't match, ask for a warning (but no error).  */
       if (TYPE_ACTUAL_ARG_TYPES (f1)
-	  && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1),
-					   flags))
+	  && 1 != type_lists_compatible_p (args2, TYPE_ACTUAL_ARG_TYPES (f1)))
 	val = 2;
       return val;
     }
@@ -986,14 +982,13 @@ function_types_compatible_p (tree f1, tr
       if (!self_promoting_args_p (args1))
 	return 0;
       if (TYPE_ACTUAL_ARG_TYPES (f2)
-	  && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2),
-					   flags))
+	  && 1 != type_lists_compatible_p (args1, TYPE_ACTUAL_ARG_TYPES (f2)))
 	val = 2;
       return val;
     }
 
   /* Both types have argument lists: compare them and propagate results.  */
-  val1 = type_lists_compatible_p (args1, args2, flags);
+  val1 = type_lists_compatible_p (args1, args2);
   return val1 != 1 ? val1 : val;
 }
 
@@ -1002,7 +997,7 @@ function_types_compatible_p (tree f1, tr
    or 2 for compatible with warning.  */
 
 static int
-type_lists_compatible_p (tree args1, tree args2, int flags)
+type_lists_compatible_p (tree args1, tree args2)
 {
   /* 1 if no need for warning yet, 2 if warning cause has been seen.  */
   int val = 1;
@@ -1035,8 +1030,7 @@ type_lists_compatible_p (tree args1, tre
 	       || TREE_CODE (TREE_VALUE (args2)) == ERROR_MARK)
 	;
       else if (! (newval = comptypes (TYPE_MAIN_VARIANT (TREE_VALUE (args1)),
-				      TYPE_MAIN_VARIANT (TREE_VALUE (args2)),
-				      flags)))
+				      TYPE_MAIN_VARIANT (TREE_VALUE (args2)))))
 	{
 	  /* Allow  wait (union {union wait *u; int *i} *)
 	     and  wait (union wait *)  to be compatible.  */
@@ -1050,8 +1044,7 @@ type_lists_compatible_p (tree args1, tre
 	      tree memb;
 	      for (memb = TYPE_FIELDS (TREE_VALUE (args1));
 		   memb; memb = TREE_CHAIN (memb))
-		if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2),
-			       flags))
+		if (comptypes (TREE_TYPE (memb), TREE_VALUE (args2)))
 		  break;
 	      if (memb == 0)
 		return 0;
@@ -1066,8 +1059,7 @@ type_lists_compatible_p (tree args1, tre
 	      tree memb;
 	      for (memb = TYPE_FIELDS (TREE_VALUE (args2));
 		   memb; memb = TREE_CHAIN (memb))
-		if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1),
-			       flags))
+		if (comptypes (TREE_TYPE (memb), TREE_VALUE (args1)))
 		  break;
 	      if (memb == 0)
 		return 0;
@@ -1837,7 +1829,7 @@ build_function_call (tree function, tree
       && TREE_CODE (function) == NOP_EXPR
       && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
       && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
-      && ! comptypes (fntype, TREE_TYPE (tem), COMPARE_STRICT))
+      && ! comptypes (fntype, TREE_TYPE (tem)))
     {
       tree return_type = TREE_TYPE (fntype);
       tree trap = build_function_call (built_in_decls[BUILT_IN_TRAP],
@@ -3013,7 +3005,7 @@ build_c_cast (tree type, tree expr)
 
       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
 	if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (field)),
-		       TYPE_MAIN_VARIANT (TREE_TYPE (value)), COMPARE_STRICT))
+		       TYPE_MAIN_VARIANT (TREE_TYPE (value))))
 	  break;
 
       if (field)
@@ -3361,7 +3353,7 @@ convert_for_assignment (tree type, tree 
      This code doesn't fully support references, it's just for the
      special case of va_start and va_copy.  */
   if (codel == REFERENCE_TYPE
-      && comptypes (TREE_TYPE (type), TREE_TYPE (rhs), COMPARE_STRICT) == 1)
+      && comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1)
     {
       if (!lvalue_p (rhs))
 	{
@@ -3409,7 +3401,7 @@ convert_for_assignment (tree type, tree 
 	  tree memb_type = TREE_TYPE (memb_types);
 
 	  if (comptypes (TYPE_MAIN_VARIANT (memb_type),
-			 TYPE_MAIN_VARIANT (rhstype), COMPARE_STRICT))
+			 TYPE_MAIN_VARIANT (rhstype)))
 	    break;
 
 	  if (TREE_CODE (memb_type) != POINTER_TYPE)
@@ -3988,7 +3980,7 @@ digest_init (tree type, tree init, int r
 	  && ((inside_init && TREE_CODE (inside_init) == STRING_CST)))
 	{
 	  if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
-			 TYPE_MAIN_VARIANT (type), COMPARE_STRICT))
+			 TYPE_MAIN_VARIANT (type)))
 	    return inside_init;
 
 	  if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
@@ -4035,8 +4027,7 @@ digest_init (tree type, tree init, int r
       {
 	if (TREE_CODE (inside_init) == VECTOR_CST
             && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
-			  TYPE_MAIN_VARIANT (type),
-			  COMPARE_STRICT))
+			  TYPE_MAIN_VARIANT (type)))
 	  return inside_init;
 	else
 	  return build_vector (type, CONSTRUCTOR_ELTS (inside_init));
@@ -4047,19 +4038,19 @@ digest_init (tree type, tree init, int r
 
   if (inside_init && TREE_TYPE (inside_init) != 0
       && (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
-		     TYPE_MAIN_VARIANT (type), COMPARE_STRICT)
+		     TYPE_MAIN_VARIANT (type))
 	  || (code == ARRAY_TYPE
-	      && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT))
+	      && comptypes (TREE_TYPE (inside_init), type))
 	  || (code == VECTOR_TYPE
-	      && comptypes (TREE_TYPE (inside_init), type, COMPARE_STRICT))
+	      && comptypes (TREE_TYPE (inside_init), type))
 	  || (code == POINTER_TYPE
 	      && TREE_CODE (TREE_TYPE (inside_init)) == ARRAY_TYPE
 	      && comptypes (TREE_TYPE (TREE_TYPE (inside_init)),
-			    TREE_TYPE (type), COMPARE_STRICT))
+			    TREE_TYPE (type)))
 	  || (code == POINTER_TYPE
 	      && TREE_CODE (TREE_TYPE (inside_init)) == FUNCTION_TYPE
 	      && comptypes (TREE_TYPE (inside_init),
-			    TREE_TYPE (type), COMPARE_STRICT))))
+			    TREE_TYPE (type)))))
     {
       if (code == POINTER_TYPE)
 	{
@@ -5500,7 +5491,7 @@ output_init_element (tree value, tree ty
 	       && TREE_CODE (type) == ARRAY_TYPE
 	       && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
 	  && !comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (value)),
-			 TYPE_MAIN_VARIANT (type), COMPARE_STRICT)))
+			 TYPE_MAIN_VARIANT (type))))
     value = default_conversion (value);
 
   if (TREE_CODE (value) == COMPOUND_LITERAL_EXPR
diff -rupN gcc.orig/objc/objc-act.c gcc/objc/objc-act.c
--- gcc.orig/objc/objc-act.c	2004-06-01 15:44:19.000000000 +0000
+++ gcc/objc/objc-act.c	2004-06-13 09:30:51.000000000 +0000
@@ -1,6 +1,6 @@
 /* Implement classes and message passing for Objective C.
    Copyright (C) 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Steve Naroff.
 
 This file is part of GCC.
@@ -4257,7 +4257,7 @@ check_ivars (tree inter, tree imp)
 
       t1 = TREE_TYPE (intdecls); t2 = TREE_TYPE (impdecls);
 
-      if (!comptypes (t1, t2, false)
+      if (!comptypes (t1, t2)
 	  || !tree_int_cst_equal (TREE_VALUE (TREE_VALUE (rawintdecls)),
 				  TREE_VALUE (TREE_VALUE (rawimpdecls))))
 	{
@@ -7612,8 +7612,7 @@ comp_method_with_proto (tree method, tre
   /* install return type */
   TREE_TYPE (function1_template) = groktypename (TREE_TYPE (proto));
 
-  return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function1_template,
-		    false);
+  return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function1_template);
 }
 
 /* Return 1 if TYPE1 is equivalent to TYPE2.  */

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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