summaryrefslogtreecommitdiff
path: root/gcc/doc/cpp.texi
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-08 21:02:31 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-08 21:02:31 +0000
commit2798f07c7bedd317fa7b596c071f0b2672d439e8 (patch)
treedcf24c4e35c90d6be02f200980d40c51523db0ad /gcc/doc/cpp.texi
parent053d448f60b0858472a312faa1362eb2fe5d5044 (diff)
downloadgcc-2798f07c7bedd317fa7b596c071f0b2672d439e8.tar.gz
* cpplex.c (cpp_interpret_charconst): Truncate as well as
sign-extend. doc: * cpp.texi: Clarify multichar charconst valuation. testsuite: * gcc.dg/cpp/charconst-4.c: More tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53301 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc/cpp.texi')
-rw-r--r--gcc/doc/cpp.texi22
1 files changed, 12 insertions, 10 deletions
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index 0e7d9e878a0..194175362a8 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -3512,19 +3512,21 @@ The preprocessor and compiler interpret character constants in the
same way; i.e.@: escape sequences such as @samp{\a} are given the
values they would have on the target machine.
-Multi-character character constants are interpreted a character at a
-time, shifting the previous result left by the number of bits per
-target character and or-ing the value of the new character truncated
-to the width of a target character. They have type @code{int}, and
-are treated as signed regardless of whether single characters are
-signed or not (a slight change from versions 3.1 and earlier of GCC).
-If there are more characters in the constant than would fit in the
-target @code{int} an error is issued.
+The compiler values a multi-character character constant a character
+at a time, shifting the previous value left by the number of bits per
+target character, and then or-ing in the bit-pattern of the new
+character truncated to the width of a target character. The final
+bit-pattern is given type @code{int}, and is therefore signed,
+regardless of whether single characters are signed or not (a slight
+change from versions 3.1 and earlier of GCC). If there are more
+characters in the constant than would fit in the target @code{int} the
+compiler issues a warning, and the excess leading characters are
+ignored.
For example, 'ab' for a target with an 8-bit @code{char} would be
interpreted as @w{(int) ((unsigned char) 'a' * 256 + (unsigned char)
-'b')}, and 'a\234' as @w{(int) ((unsigned char) 'a' * 256 + (unsigned
-char) '\234')}.
+'b')}, and '\234a' as @w{(int) ((unsigned char) '\234' * 256 + (unsigned
+char) 'a')}.
@item Source file inclusion.