Commit a38b987a by Neil Booth Committed by Neil Booth

c-typeck.c (convert_arguments): When comparing for enumeral type equality, use TYPE_MAIN_VARIANT.

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

From-SVN: r46559
parent 30151c7b
2001-10-26 Neil Booth <neil@daikokuya.demon.co.uk>
* c-typeck.c (convert_arguments): When comparing for enumeral
type equality, use TYPE_MAIN_VARIANT.
* gcc.dg/Wconversion.c: New tests.
2001-10-26 Kazu Hirata <kazu@hxi.com> 2001-10-26 Kazu Hirata <kazu@hxi.com>
* s390/s390.c: Fix comment typos. * s390/s390.c: Fix comment typos.
......
...@@ -1651,7 +1651,8 @@ convert_arguments (typelist, values, name, fundecl) ...@@ -1651,7 +1651,8 @@ convert_arguments (typelist, values, name, fundecl)
tree type1 = TREE_TYPE (would_have_been); tree type1 = TREE_TYPE (would_have_been);
if (TREE_CODE (type) == ENUMERAL_TYPE 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 /* No warning if function asks for enum
and the actual arg is that enum type. */ and the actual arg is that enum type. */
; ;
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment