summaryrefslogtreecommitdiff
path: root/gcc/cppexp.c
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-02 19:37:34 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-02 19:37:34 +0000
commitf5ec8cb5950aa7471a955979c0aea3019dab2a54 (patch)
tree8660e3e7cbb02e35bffcba5d9bb626eaddc20430 /gcc/cppexp.c
parentc003992af6319067d9c18098740b83fe2b4ee4ca (diff)
downloadgcc-f5ec8cb5950aa7471a955979c0aea3019dab2a54.tar.gz
* c-common.c (c_common_init): Override cpplib's default
warn_long_long setting. * c-lex.c (lex_number): Replace with interpret_integer, interpret_float, narrowest_unsigned_type and narrowest_signed_type, taking advantage of the new cpplib functionality. * cpperror.c (_cpp_begin_message): If a warning is turned into an error, avoid printing "warning:". * cppexp.c (cpp_num_sign_extend): New. * cppinit.c: Update comment. * cpplib.h (cpp_num_sign_extend): New. * tree.h: Update comment. testsuite: * gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-suffix-1.c, gcc.dg/cpp/paste4.c, gcc.dg/cpp/sysmac2.c: Update for mofified diagnostics. * gcc.dg/c99-intconst-1.c: No longer fail. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54180 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppexp.c')
-rw-r--r--gcc/cppexp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/cppexp.c b/gcc/cppexp.c
index 1153768dedd..e5f464eaa00 100644
--- a/gcc/cppexp.c
+++ b/gcc/cppexp.c
@@ -995,6 +995,33 @@ num_positive (num, precision)
return (num.low & (cpp_num_part) 1 << (precision - 1)) == 0;
}
+/* Sign extend a number, with PRECISION significant bits and all
+ others assumed clear, to fill out a cpp_num structure. */
+cpp_num
+cpp_num_sign_extend (num, precision)
+ cpp_num num;
+ size_t precision;
+{
+ if (!num.unsignedp)
+ {
+ if (precision > PART_PRECISION)
+ {
+ precision -= PART_PRECISION;
+ if (precision < PART_PRECISION
+ && (num.high & (cpp_num_part) 1 << (precision - 1)))
+ num.high |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
+ }
+ else if (num.low & (cpp_num_part) 1 << (precision - 1))
+ {
+ if (precision < PART_PRECISION)
+ num.low |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
+ num.high = ~(cpp_num_part) 0;
+ }
+ }
+
+ return num;
+}
+
/* Returns the negative of NUM. */
static cpp_num
num_negate (num, precision)