summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-23 23:49:32 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-23 23:49:32 +0000
commita359431fb8dad9925af4f9f0517eebd0baacf118 (patch)
treecfc882b1b4637780b15a77b7142e30441226ffc1
parented54c473cbb8295776f9ae25125815f08e68f4e1 (diff)
downloadgcc-a359431fb8dad9925af4f9f0517eebd0baacf118.tar.gz
* c-typeck.c (c_start_case): Don't strip conversions from the
controlling expression. Partially fixes PR c/2454. testsuite: * gcc.c-torture/execute/20011223-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48292 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20011223-1.c22
4 files changed, 31 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d2d73ea437f..1b84b719068 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 50d7f9bf5d2..eacf4f56691 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 fadeb19fe39..68f0c616887 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 00000000000..18fb7208927
--- /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);
+ }
+}