diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-08 12:01:59 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-08 12:01:59 +0000 |
commit | 61a8313947d5d014ebd5bfcc831f2613bd833296 (patch) | |
tree | af1bbb1acd95fad4ba7823197532eaeafdd00ff3 /gcc/c-lex.c | |
parent | cfb3c5b1d76daa7554f2a0103e3c6dc9e829ce03 (diff) | |
download | gcc-61a8313947d5d014ebd5bfcc831f2613bd833296.tar.gz |
* c-lex.c (c_lex): Peek a token ahead for a string to concatenate,
using combine_strings to do the concatenation.
* c-parse.in: Replace uses of the string non-terminal with STRING.
Don't attempt string concatenation.
(OBJC_STRING): New terminal.
(string): Remove non-terminal.
(_yylex): Call combine_strings on function names. Generate
OBJC_STRING terminals; don't pass '@' on to yacc.
* c-typeck.c (simple_asm_stmt): Don't concatenate strings here.
(build_asm_stmt): Similarly.
cp:
* parse.y: Replace uses of the string non-terminal with STRING.
Don't perform string concatentaion here.
(string): Remove non-terminal.
* semantics.c (finish_asm_stmt): Don't concatenate strings here.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47792 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index e70be7028e6..84d64f16768 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -762,6 +762,7 @@ c_lex (value) tree *value; { const cpp_token *tok; + enum cpp_ttype result; retry: timevar_push (TV_CPP); @@ -776,7 +777,9 @@ c_lex (value) lineno = src_lineno; *value = NULL_TREE; - switch (tok->type) + result = tok->type; + + switch (result) { case CPP_OPEN_BRACE: indent_level++; break; case CPP_CLOSE_BRACE: indent_level--; break; @@ -804,8 +807,48 @@ c_lex (value) case CPP_STRING: case CPP_WSTRING: - *value = lex_string ((const char *)tok->val.str.text, - tok->val.str.len, tok->type == CPP_WSTRING); + { + tree full_str = NULL_TREE; + + do + { + /* Translate escape sequences in this string, then append it. */ + tree str = lex_string ((const char *) tok->val.str.text, + tok->val.str.len, + tok->type == CPP_WSTRING); + + if (full_str && c_language == clk_c && warn_traditional + && !in_system_header) + { + static int last_lineno; + static const char *last_input_filename; + + if (lineno != last_lineno || !last_input_filename + || strcmp (last_input_filename, input_filename)) + { + warning ("traditional C rejects string concatenation"); + last_lineno = lineno; + last_input_filename = input_filename; + } + } + + full_str = chainon (full_str, str); + + /* Wide and non-wide give a wide result. */ + if (tok->type == CPP_WSTRING) + result = CPP_WSTRING; + + /* Look ahead for another string token. */ + do + tok = cpp_get_token (parse_in); + while (tok->type == CPP_PADDING); + } + while (tok->type == CPP_STRING || tok->type == CPP_WSTRING); + + _cpp_backup_tokens (parse_in, 1); + + *value = combine_strings (full_str); + } break; /* These tokens should not be visible outside cpplib. */ @@ -817,7 +860,7 @@ c_lex (value) default: break; } - return tok->type; + return result; } #define ERROR(msgid) do { error(msgid); goto syntax_error; } while(0) |