This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] gcc.dg/compare1.c: Add -fno-short-enums.
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Kazu Hirata <kazu at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 03 Jul 2005 17:35:20 +0200
- Subject: Re: [patch] gcc.dg/compare1.c: Add -fno-short-enums.
- References: <200507031518.j63FIX3U020950@sethra.codesourcery.com>
Kazu Hirata <kazu@codesourcery.com> writes:
| Hi,
|
| Attached is a patch to add -fno-short-enums.
|
| Consider
|
| int i(enum mm2 x)
| {
| return x == (tf?DI2:-1); /* { dg-warning "signed and unsigned" "case 4" } */
| }
|
| The rhs of == is of type int because of -1. Now, 'x' is of type mm2
| and promoted to int. Since int covers the entire range of mm2,
| c-typeck.c:build_binary_op decides not to issue a "comparison between
| signed and unsigned" warning. The following "if" statement is
| responsible for this decision:
|
| Do not warn if the comparison is being done in a signed type,
| since the signed type will only be chosen if it can represent
| all the values of the unsigned type. */
| if (!TYPE_UNSIGNED (result_type))
| /* OK */;
|
| The patch solves the problem as suggested by Paul Brook. (Thanks
| Paul!) Specifically, if we add -fno-short-enums, we can force targets
| like arm*-*-eabi* and arm*-*-symbianelf* as well as other targets to
| use enum of the same size as int. This way, even if somebody adds a
| port with short enum, we won't have to touch this testcase.
|
| Tested on x86_64-pc-linux-gnu and arm-none-eabi. OK to apply?
I do not understand. Why don't you add a new separate testcase for
the kind of thing you would like to test? If this specific testcase
is expected to fail on arm*-*-eabi* and arm*-*-symbianelf* then you
should mark it as XFAIL for those targets.
-- Gaby