diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-08-05 21:31:30 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-08-05 21:31:30 +0000 |
commit | 6604e6f38d99e2e38f997d3ddb56a8fef06818b2 (patch) | |
tree | ba4516faab4daa3b5f2b20d3f9b83a34c0baede5 /gcc | |
parent | 67821e3a9e007c34a85bbc3b934031b57eafc903 (diff) | |
download | gcc-6604e6f38d99e2e38f997d3ddb56a8fef06818b2.zip gcc-6604e6f38d99e2e38f997d3ddb56a8fef06818b2.tar.gz gcc-6604e6f38d99e2e38f997d3ddb56a8fef06818b2.tar.bz2 |
re PR preprocessor/3824 (With -traditional, CPP 0xffffffff > 0 but C 0xffffffff < 0)
PR preprocessor/3824
* line-map.c: Update comments.
* line-map.h: Update comments.
* tradcif.y: Don't consider large numbers unsigned.
* gcc.dg/cpp/tr-sign.c: New testcase.
From-SVN: r44651
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/line-map.c | 5 | ||||
-rw-r--r-- | gcc/line-map.h | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/tr-sign.c | 18 | ||||
-rw-r--r-- | gcc/tradcif.y | 6 |
6 files changed, 43 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 70f07e3..4cdd33c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2001-08-05 Neil Booth <neil@daikokuya.demon.co.uk> + PR preprocessor/3824 + * line-map.c: Update comments. + * line-map.h: Update comments. + * tradcif.y: Don't consider large numbers unsigned. + +2001-08-05 Neil Booth <neil@daikokuya.demon.co.uk> + PR preprocessor/3081 * c-lex.c (map): New. (cb_file_change): Update map and use it. diff --git a/gcc/line-map.c b/gcc/line-map.c index a67191d..27bcf2f 100644 --- a/gcc/line-map.c +++ b/gcc/line-map.c @@ -93,7 +93,10 @@ add_line_map (set, reason, from_line, to_file, to_line) return map; } -/* Translate a logical line number into a (source file, line) pair. */ +/* Given a logical line, returns the map from which the corresponding + (source file, line) pair can be deduced. Since the set is built + chronologically, the logical lines are monotonic increasing, and so + the list is sorted and we can use a binary search. */ struct line_map * lookup_line (set, line) diff --git a/gcc/line-map.h b/gcc/line-map.h index b6c9344..bbc6caa 100644 --- a/gcc/line-map.h +++ b/gcc/line-map.h @@ -44,7 +44,11 @@ struct line_maps unsigned int used; }; -/* Reason for adding a line change with add_line_map (). */ +/* Reason for adding a line change with add_line_map (). LC_ENTER is + when including a new file, e.g. a #include directive in C. + LC_LEAVE is when reaching a file's end. LC_RENAME is when a file + name or line number changes for neither of the above reasons + (e.g. a #line directive in C). */ enum lc_reason {LC_ENTER = 0, LC_LEAVE, LC_RENAME}; /* Initialize a line map set. */ @@ -56,7 +60,7 @@ extern void free_line_maps PARAMS ((struct line_maps *)); /* Add a mapping of logical source line to physical source file and - line number. Ther text pointed to by TO_FILE must have a lifetime + line number. The text pointed to by TO_FILE must have a lifetime at least as long as the final call to lookup_line (). FROM_LINE should be monotonic increasing across calls to this @@ -80,7 +84,8 @@ extern struct line_map *lookup_line /* Non-zero if the map is at the bottom of the include stack. */ #define MAIN_FILE_P(MAP) ((MAP)->included_from < 0) -/* The current line map. */ +/* The current line map. Saves a call to lookup_line if the caller is + sure he is in the scope of the current map. */ #define CURRENT_LINE_MAP(MAPS) ((MAPS)->maps + (MAPS)->used - 1) #endif /* !GCC_LINE_MAP_H */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 512f539..9e3c8c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2001-08-05 Neil Booth <neil@daikokuya.demon.co.uk> + * gcc.dg/cpp/tr-sign.c: New testcase. + +2001-08-05 Neil Booth <neil@daikokuya.demon.co.uk> + * gcc.dg/cpp/19951025-1.c: Revert. * gcc.dg/cpp/directiv.c: We no longer process directives that interrupt macro arguments. diff --git a/gcc/testsuite/gcc.dg/cpp/tr-sign.c b/gcc/testsuite/gcc.dg/cpp/tr-sign.c new file mode 100644 index 0000000..e48e8cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/tr-sign.c @@ -0,0 +1,18 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. */ + +/* { dg-do preprocess { target i?86-*-* } } */ + +/* { dg-options "-traditional" } */ + +/* Tests that traditional numbers are signed, unless otherwise + specified. This test assumes a 32 bit target. + + Neil Booth, 5 Aug 2001. Inspired by PR 3824. */ + +#if 0xffffffff >= 0 +# error 0xffffffff /* { dg-bogus "0xffffffff" "0xffffffff positive" } */ +#endif + +#if 0xffffffffU <= 0 +# error 0xffffffffU /* { dg-bogus "0xffffffffU" "0xffffffffU negative" } */ +#endif diff --git a/gcc/tradcif.y b/gcc/tradcif.y index 5def3c9..771f9d2 100644 --- a/gcc/tradcif.y +++ b/gcc/tradcif.y @@ -231,6 +231,8 @@ parse_number (olen) return ERROR; } + /* Traditionally, all numbers are signed. However, we make it + unsigned if requested with a suffix. */ yylval.integer.unsignedp = 0; if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) { @@ -277,10 +279,6 @@ parse_number (olen) return ERROR; } - /* If too big to be signed, consider it unsigned. */ - if (n < 0) - yylval.integer.unsignedp = 1; - lexptr = p; yylval.integer.value = n; return INT; |