diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-typeck.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20011223-1.c | 22 |
4 files changed, 31 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2d73ea..1b84b71 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2001-12-23 Joseph S. Myers <jsm28@cam.ac.uk> + * c-typeck.c (c_start_case): Don't strip conversions from the + controlling expression. Partially fixes PR c/2454. + +2001-12-23 Joseph S. Myers <jsm28@cam.ac.uk> + * Makefile.in (USER_H): Remove proto.h. * config.gcc (c*-convex-*): Set extra_headers=proto.h. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 50d7f9b..eacf4f5 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -7125,7 +7125,6 @@ c_start_case (exp) } else { - tree index; type = TYPE_MAIN_VARIANT (TREE_TYPE (exp)); if (warn_traditional && !in_system_header @@ -7135,14 +7134,6 @@ c_start_case (exp) exp = default_conversion (exp); type = TREE_TYPE (exp); - index = get_unwidened (exp, NULL_TREE); - /* We can't strip a conversion from a signed type to an - unsigned, because if we did, int_fits_type_p would do the - wrong thing when checking case values for being in range, - and it's too hard to do the right thing. */ - if (TREE_UNSIGNED (TREE_TYPE (exp)) - == TREE_UNSIGNED (TREE_TYPE (index))) - exp = index; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fadeb19..68f0c61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-12-23 Joseph S. Myers <jsm28@cam.ac.uk> + + * gcc.c-torture/execute/20011223-1.c: New test. + 2001-12-21 Richard Henderson <rth@redhat.com> * gcc.dg/wtr-aggr-init-1.c: Test that __extension__ disables then diff --git a/gcc/testsuite/gcc.c-torture/execute/20011223-1.c b/gcc/testsuite/gcc.c-torture/execute/20011223-1.c new file mode 100644 index 0000000..18fb720 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20011223-1.c @@ -0,0 +1,22 @@ +/* Origin: Joseph Myers <jsm28@cam.ac.uk>. */ +/* Case labels in a switch statement are converted to the promoted + type of the controlling expression, not an unpromoted version. + Reported as PR c/2454 by + Andreas Krakowczyk <Andreas.Krakowczyk@fujitsu-siemens.com>. */ + +extern void exit (int); +extern void abort (void); + +static int i; + +int +main (void) +{ + i = -1; + switch ((signed char) i) { + case 255: + abort (); + default: + exit (0); + } +} |