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 a regression due to my recent composite_type changes



On Jun 23, 2004, at 12:33 PM, Joseph S. Myers wrote:


On Wed, 23 Jun 2004, Andrew Pinski wrote:

I noticed after my patch to composite_type that I introduced a
regression
but there is no testcase for it yet in the testsuite :(.
This patch fixes that regression as you cannot use qualify_type with
array
types as it uses c_build_qualified_type which touches the wrong type
when building the new type.  I also implemented a little memory

Array types should never be qualified - only the element type should be -
so I think it would be better to abort in the case of array types if there
are any qualifiers.


You are right then the only thing which needs to change is the removal of
the qualify_type from the ARRAY_TYPE case in composite_type which I should
not have added in the first place.


So this patch which I tested on powerpc-apple-darwin with no regressions
does just that and it also keeps the memory saving which I added and it
adds a check for making sure that the TYPE_QUALS on arrays are not set
at all.

OK?

Thanks,
Andrew Pinski

ChangeLog:

	* c-typeck.c (composite_type, <case ARRAY_TYPE>): Abort if we have
	type qualifiers at all.
	If both of the type domains are null and the new element type is the
	same as one of the, return the one which the element type matches.
	Do not call qualify_type on the new type.

Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.328
diff -u -p -r1.328 c-typeck.c
--- c-typeck.c	23 Jun 2004 17:05:42 -0000	1.328
+++ c-typeck.c	23 Jun 2004 19:45:15 -0000
@@ -260,15 +260,25 @@ composite_type (tree t1, tree t2)
     case ARRAY_TYPE:
       {
 	tree elt = composite_type (TREE_TYPE (t1), TREE_TYPE (t2));
+	
+	/* We should not have any type quals on arrays at all.  */
+	if (TYPE_QUALS (t1) || TYPE_QUALS (t2))
+	  abort ();
+	
 	/* Save space: see if the result is identical to one of the args.  */
 	if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1))
 	  return build_type_attribute_variant (t1, attributes);
 	if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2))
 	  return build_type_attribute_variant (t2, attributes);
+	
+	if (elt == TREE_TYPE (t1) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
+	  return build_type_attribute_variant (t1, attributes);
+	if (elt == TREE_TYPE (t2) && !TYPE_DOMAIN (t2) && !TYPE_DOMAIN (t1))
+	  return build_type_attribute_variant (t2, attributes);
+	
 	/* Merge the element types, and have a size if either arg has one.  */
 	t1 = build_array_type (elt, TYPE_DOMAIN (TYPE_DOMAIN (t1) ? t1 : t2));
-	t1 = build_type_attribute_variant (t1, attributes);
-	return qualify_type (t1, t2);
+	return build_type_attribute_variant (t1, attributes);
       }

case FUNCTION_TYPE:


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