cpplex.c (cpp_interpret_charconst): Use HOST_WIDE_INT for sign extension.
authorAndreas Jaeger <aj@gcc.gnu.org>
Fri, 23 Nov 2001 10:01:16 +0000 (11:01 +0100)
committerAndreas Jaeger <aj@gcc.gnu.org>
Fri, 23 Nov 2001 10:01:16 +0000 (11:01 +0100)
* cpplex.c (cpp_interpret_charconst): Use HOST_WIDE_INT for sign
extension.

* gcc.dg/cpp/charconst-2.c: New test.

From-SVN: r47286

gcc/ChangeLog
gcc/cpplex.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/charconst-2.c [new file with mode: 0644]

index 02549e6a85e1bbf36115e74af939c7c06f90c0f8..945a57db0a5a590c9ac8be0616ec9ed0372b1d6b 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-23  Andreas Jaeger  <aj@suse.de>
+
+       * cpplex.c (cpp_interpret_charconst): Use HOST_WIDE_INT for sign
+       extension.
+
 2001-11-23  Nick Clifton  <nickc@cambridge.redhat.com>
 
        * config/arm/xscale-coff.h (SUBTARGET_CPU_DEFAULT): Override
@@ -67,9 +72,9 @@ Thu Nov 22 06:49:14 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * tree-dump.c: Rename from c-dump.c. Include c-tree.h, not c-common.h.
        (lang_type_quals): Declare.
-       (dequeue_and_dump): Use lang_hooks.tree_dump.type_quals function to 
-       retrieve language-specific qualifiers for a type node, instead of 
-       C_TYPE_QUALS. Likewise for lang_hooks.tree_dump.dump_tree instead of 
+       (dequeue_and_dump): Use lang_hooks.tree_dump.type_quals function to
+       retrieve language-specific qualifiers for a type node, instead of
+       C_TYPE_QUALS. Likewise for lang_hooks.tree_dump.dump_tree instead of
        lang_dump_tree.
        * tree-dump.h: Rename from c-dump.h.
        * c-common.h (C_TYPE_QUALS): Removed.
@@ -120,7 +125,7 @@ Thu Nov 22 06:49:14 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
        * v850.h (DBX_REGISTER_NUMBER): Likewise.
        * vax.h (DBX_REGISTER_NUMBER): Likewise.
        * we32k.h (DBX_REGISTER_NUMBER): Likewise.
-       
+
        * defaults.h (DBX_REGISTER_NUMBER): Provide a default.
        * doc/tm.texi (DBX_REGISTER_NUMBER): Update.
 
index 924863f1fcac4660d920b3f10c49a02cab83792e..35411e615c1c3f6d81115fa94f412be5bb5b1ef1 100644 (file)
@@ -1,5 +1,5 @@
 /* CPP Library - lexical analysis.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -1922,8 +1922,8 @@ cpp_interpret_charconst (pfile, token, warn_multi, traditional, pchars_seen)
   if (token->type == CPP_CHAR && chars_seen)
     {
       unsigned int nbits = chars_seen * width;
-      unsigned int mask = (unsigned int) ~0 >> (HOST_BITS_PER_INT - nbits);
 
+      mask = (unsigned HOST_WIDE_INT) ~0 >> (HOST_BITS_PER_WIDE_INT - nbits);
       if (pfile->spec_nodes.n__CHAR_UNSIGNED__->type == NT_MACRO
          || ((result >> (nbits - 1)) & 1) == 0)
        result &= mask;
index ac3dfc0758c800274018ec604c62e44a7ef616c1..5105842bcbc039e2ca499bad54c75b0c97191eec 100644 (file)
@@ -1,3 +1,7 @@
+2001-11-23  Andreas Jaeger  <aj@suse.de>
+
+       * gcc.dg/cpp/charconst-2.c: New test.
+
 2001-11-22  Geoffrey Keating  <geoffk@redhat.com>
 
        * lib/old-dejagnu.exp (old-dejagnu): Copy extra source files
@@ -340,7 +344,7 @@ Mon Oct 29 21:19:53 2001  Nicola Pero  <n.pero@mi.flashnet.it>
 2001-09-27  Geoffrey Keating  <geoffk@redhat.com>
 
        * gcc.c-torture/execute/loop-2e.x: This is a manifestation of a
-       long-standing bug on i686, apparently.  
+       long-standing bug on i686, apparently.
        * gcc.c-torture/execute/loop-2c.x: New file.
        * gcc.c-torture/execute/loop-2d.x: New file.
        * gcc.c-torture/execute/loop-3c.x: New file.
@@ -360,7 +364,7 @@ Mon Oct 29 21:19:53 2001  Nicola Pero  <n.pero@mi.flashnet.it>
 2001-09-24  DJ Delorie  <dj@redhat.com>
 
        * gcc.c-torture/execute/20010924-1.c: New test.
-       
+
 2001-09-24  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * testsuite/objc/execute/paste.m: Remove.
@@ -408,7 +412,7 @@ Mon Oct 29 21:19:53 2001  Nicola Pero  <n.pero@mi.flashnet.it>
 
 2001-09-15  Aldy Hernandez  <aldyh@redhat.com>
 
-        * gcc.c-torture/execute/980223.c: Change type of addr from long 
+        * gcc.c-torture/execute/980223.c: Change type of addr from long
        to char *.
 
 2001-09-15  Hans-Peter Nilsson  <hp@axis.com>
@@ -474,7 +478,7 @@ Mon Oct 29 21:19:53 2001  Nicola Pero  <n.pero@mi.flashnet.it>
 2001-09-05  Ziemowit Laski  <zlaski@apple.com>
 
        * objc.dg/method-2.m: New.
-       
+
 2001-09-04  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/4203
@@ -566,8 +570,8 @@ Mon Oct 29 21:19:53 2001  Nicola Pero  <n.pero@mi.flashnet.it>
 2001-08-14  David Billinghurst  <David.Billinghurst@riotinto.com>
 
        * lib/g77-dg.exp:  Use prune.exp for common procedures
-       (g77-dg-prune): Replace prune_g77_output with prune_gcc_output 
-       * lib/g77.exp: (g77-dg-prune) Remove 
+       (g77-dg-prune): Replace prune_g77_output with prune_gcc_output
+       * lib/g77.exp: (g77-dg-prune) Remove
 
 2001-08-13  Jason Merrill  <jason_merrill@redhat.com>
 
diff --git a/gcc/testsuite/gcc.dg/cpp/charconst-2.c b/gcc/testsuite/gcc.dg/cpp/charconst-2.c
new file mode 100644 (file)
index 0000000..7ee0cfb
--- /dev/null
@@ -0,0 +1,18 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.  */
+
+/* { dg-do compile } */
+
+/* Crosscompiling from i686-linux (32-bit) to x86_64-linux (64-bit)
+   gave extra warnings on the two assignments:
+   warning: large integer implicitly truncated to unsigned type
+   warning: overflow in implicit constant conversion
+   This test has been added as a regression test after fixing the bug
+   by Andreas Jaeger, 23 Nov 2001.  */
+int
+main (void)
+{
+  signed char c = '\xff';
+  unsigned char d = '\xff';
+  
+  return 0;
+}