aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-12-08 12:01:59 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-12-08 12:01:59 +0000
commitcb97d97deebd67dc9988b51210f1432ecb924145 (patch)
treeaf1bbb1acd95fad4ba7823197532eaeafdd00ff3 /gcc/c-lex.c
parent18d6067bcd57dcc02099060cf91717faaca0b05b (diff)
downloadgcc-cb97d97deebd67dc9988b51210f1432ecb924145.zip
gcc-cb97d97deebd67dc9988b51210f1432ecb924145.tar.gz
gcc-cb97d97deebd67dc9988b51210f1432ecb924145.tar.bz2
c-lex.c (c_lex): Peek a token ahead for a string to concatenate...
* 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. From-SVN: r47792
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index e70be70..84d64f1 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)