aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2001-12-23 23:49:32 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2001-12-23 23:49:32 +0000
commit6eb5351149fbe37f06c43bacb968e71bd73dfbb5 (patch)
treecfc882b1b4637780b15a77b7142e30441226ffc1 /gcc
parentb31bbca2fe191ef1ac1b31872a57328b916ef735 (diff)
downloadgcc-6eb5351149fbe37f06c43bacb968e71bd73dfbb5.zip
gcc-6eb5351149fbe37f06c43bacb968e71bd73dfbb5.tar.gz
gcc-6eb5351149fbe37f06c43bacb968e71bd73dfbb5.tar.bz2
re PR c/2454 (Test Program A0376972.c fails with gcc-20010320, works with gcc-2.95.3)
* 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. From-SVN: r48292
Diffstat (limited to 'gcc')
-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 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);
+ }
+}