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]

c: Fix PR 137.


This fixes PR 137.  OK to commit assuming no regressions?

Neil.

	* c-typeck.c (convert_arguments): When comparing for enumeral
	type equality, use TYPE_MAIN_VARIANT.
	* gcc.dg/Wconversion.c: New tests.

Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.143
diff -u -p -r1.143 c-typeck.c
--- c-typeck.c	2001/10/24 20:10:51	1.143
+++ c-typeck.c	2001/10/26 19:35:06
@@ -1651,7 +1651,8 @@ convert_arguments (typelist, values, nam
 		      tree type1 = TREE_TYPE (would_have_been);
 
 		      if (TREE_CODE (type) == ENUMERAL_TYPE
-			  && type == TREE_TYPE (val))
+			  && (TYPE_MAIN_VARIANT (type)
+			       == TYPE_MAIN_VARIANT (TREE_TYPE (val))))
 			/* No warning if function asks for enum
 			   and the actual arg is that enum type.  */
 			;
Index: testsuite/gcc.dg/Wconversion.c
===================================================================
RCS file: Wconversion.c
diff -N Wconversion.c
--- /dev/null	Tue May  5 13:32:27 1998
+++ Wconversion.c	Fri Oct 26 12:35:06 2001
@@ -0,0 +1,20 @@
+/* Source: PR 137.
+
+   We would not warn about passing an enum, but would warn about
+   passing a enum that was part of an array.  TYPE_MAIN_VARIANT was
+   not used in the appropriate place in the warning code.  */
+
+/* { dg-do compile } */
+/* { dg-options -Wconversion } */
+
+typedef enum { a } __attribute__((packed)) t;
+void f(t x) {}
+
+int main(void)
+{
+  t x[2], y;
+  f(x[0]);			/* { dg-bogus "different width" } */
+  f(y);				/* { dg-bogus "different width" } */
+  return 0;
+}
+


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