diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-12-10 20:08:59 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-12-10 20:08:59 +0000 |
commit | a23c9413df6f956abfda9d7e73e70a7109ae7be7 (patch) | |
tree | 388abb74ae9bdd4ee8004d380c37d8256154a4ec /gcc/c-parse.in | |
parent | d01f3474229a6b3b89085ff009ba85515c95b285 (diff) | |
download | gcc-a23c9413df6f956abfda9d7e73e70a7109ae7be7.zip gcc-a23c9413df6f956abfda9d7e73e70a7109ae7be7.tar.gz gcc-a23c9413df6f956abfda9d7e73e70a7109ae7be7.tar.bz2 |
c-lex.c, [...]: Revert concatenation changes.
* c-lex.c, c-parse.in, c-typeck.c: Revert concatenation changes.
cp:
* parse.y, semantics.c: Similarly.
From-SVN: r47848
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 107 |
1 files changed, 72 insertions, 35 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 84d1c02..1602b92 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -99,8 +99,9 @@ end ifobjc yylval is the node for the constant. */ %token CONSTANT -/* A STRING_CST with type an array of the appropriate character type. */ -%token STRING OBJC_STRING +/* String constants in raw form. + yylval is a STRING_CST node. */ +%token STRING /* "...", used for functions with variable arglists. */ %token ELLIPSIS @@ -150,7 +151,7 @@ end ifobjc %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist -%type <ttype> expr_no_commas cast_expr unary_expr primary STRING +%type <ttype> expr_no_commas cast_expr unary_expr primary string STRING %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea @@ -203,8 +204,6 @@ end ifobjc %type <lineno> save_lineno ifobjc -%token OBJC_STRING - /* the Objective-C nonterminals */ %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator @@ -215,7 +214,7 @@ ifobjc %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr %type <ttype> objc_string non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr -%type <ttype> CLASSNAME OBJECTNAME OBJC_STRING +%type <ttype> CLASSNAME OBJECTNAME end ifobjc %{ @@ -348,8 +347,14 @@ extdef: ifobjc | objcdef end ifobjc - | ASM_KEYWORD '(' STRING ')' ';' - { assemble_asm ($3); } + | ASM_KEYWORD '(' expr ')' ';' + { STRIP_NOPS ($3); + if ((TREE_CODE ($3) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST) + || TREE_CODE ($3) == STRING_CST) + assemble_asm ($3); + else + error ("argument of `asm' is not a constant string"); } | extension extdef { RESTORE_WARN_FLAGS ($1); } ; @@ -613,8 +618,8 @@ primary: $$ = build_external_ref ($1, yychar == '('); } | CONSTANT - | STRING - { $$ = $1; } + | string + { $$ = combine_strings ($1); } | VAR_FUNC_NAME { $$ = fname_decl (C_RID_CODE ($$), $$); } | '(' typename ')' '{' @@ -724,13 +729,37 @@ ifobjc end ifobjc ; +/* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */ +string: + STRING + | string STRING + { +ifc + static int last_lineno = 0; + static const char *last_input_filename = 0; +end ifc + $$ = chainon ($1, $2); +ifc + if (warn_traditional && !in_system_header + && (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; + } +end ifc + } + ; + ifobjc -/* Chains ObjC string objects together. */ +/* Produces an STRING_CST with perhaps more STRING_CSTs chained + onto it, which is to be read as an ObjC string object. */ objc_string: - OBJC_STRING - { $$ = $1; } - | objc_string OBJC_STRING - { $$ = chainon ($1, $2); } + '@' STRING + { $$ = $2; } + | objc_string '@' STRING + { $$ = chainon ($1, $3); } ; end ifobjc @@ -1363,8 +1392,10 @@ notype_initdecls: maybeasm: /* empty */ { $$ = NULL_TREE; } - | ASM_KEYWORD '(' STRING ')' - { $$ = $3; } + | ASM_KEYWORD '(' string ')' + { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); + $$ = $3; + } ; initdcl: @@ -2320,20 +2351,20 @@ stmt: | RETURN expr ';' { stmt_count++; $$ = c_expand_return ($2); } - | ASM_KEYWORD maybe_type_qual '(' STRING ')' ';' + | ASM_KEYWORD maybe_type_qual '(' expr ')' ';' { stmt_count++; $$ = simple_asm_stmt ($4); } /* This is the case with just output operands. */ - | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ')' ';' + | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';' { stmt_count++; $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); } /* This is the case with input operands as well. */ - | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ':' + | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';' { stmt_count++; $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); } /* This is the case with clobbered registers as well. */ - | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ':' + | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ':' asm_clobbers ')' ';' { stmt_count++; $$ = build_asm_stmt ($2, $4, $6, $8, $10); } @@ -2422,10 +2453,10 @@ asm_operand: ; asm_clobbers: - STRING - { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); } - | asm_clobbers ',' STRING - { $$ = tree_cons (NULL_TREE, $3, $1); } + string + { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); } + | asm_clobbers ',' string + { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); } ; /* This is what appears inside the parens in a function declarator. @@ -3572,8 +3603,7 @@ end ifobjc to string constants. */ const char *name = fname_string (rid_code); - yylval.ttype - = combine_strings (build_string (strlen (name) + 1, name)); + yylval.ttype = build_string (strlen (name) + 1, name); last_token = CPP_STRING; /* so yyerror won't choke */ return STRING; } @@ -3690,16 +3720,23 @@ _yylex () special significance. */ case CPP_ATSIGN: ifobjc - last_token = c_lex (&yylval.ttype); + { + tree after_at; + enum cpp_ttype after_at_type; - if (last_token == CPP_NAME - && C_IS_RESERVED_WORD (yylval.ttype) - && OBJC_IS_AT_KEYWORD (C_RID_CODE (yylval.ttype))) - return rid_to_yy [(int) C_RID_CODE (yylval.ttype)]; - else if (last_token == CPP_STRING || last_token == CPP_WSTRING) - return OBJC_STRING; + after_at_type = c_lex (&after_at); - /* Fall through... */ + if (after_at_type == CPP_NAME + && C_IS_RESERVED_WORD (after_at) + && OBJC_IS_AT_KEYWORD (C_RID_CODE (after_at))) + { + yylval.ttype = after_at; + last_token = after_at_type; + return rid_to_yy [(int) C_RID_CODE (after_at)]; + } + _cpp_backup_tokens (parse_in, 1); + return '@'; + } end ifobjc /* These tokens are C++ specific (and will not be generated |