+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.
}
else
{
- tree index;
type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
if (warn_traditional && !in_system_header
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;
}
}
+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
--- /dev/null
+/* 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);
+ }
+}