Commit 78e78537 by Neil Booth Committed by Neil Booth

c-parse.in: Take string literals in assembler constructs, not expressions.

	* c-parse.in: Take string literals in assembler constructs,
	not expressions.
	* c-typeck.c (build_asm_stmt, simple_asm_stmt): No need to
	check the strings are STRING_CSTs.

From-SVN: r47795
parent 46af705a
2001-12-08 Neil Booth <neil@daikokuya.demon.co.uk> 2001-12-08 Neil Booth <neil@daikokuya.demon.co.uk>
* c-parse.in: Take string literals in assembler constructs,
not expressions.
* c-typeck.c (build_asm_stmt, simple_asm_stmt): No need to
check the strings are STRING_CSTs.
2001-12-08 Neil Booth <neil@daikokuya.demon.co.uk>
* 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. using combine_strings to do the concatenation.
* c-parse.in: Replace uses of the string non-terminal with STRING. * c-parse.in: Replace uses of the string non-terminal with STRING.
......
...@@ -99,7 +99,7 @@ end ifobjc ...@@ -99,7 +99,7 @@ end ifobjc
yylval is the node for the constant. */ yylval is the node for the constant. */
%token CONSTANT %token CONSTANT
/* String constants as arrays of the appropriate character type. */ /* A STRING_CST with type an array of the appropriate character type. */
%token STRING OBJC_STRING %token STRING OBJC_STRING
/* "...", used for functions with variable arglists. */ /* "...", used for functions with variable arglists. */
...@@ -348,14 +348,8 @@ extdef: ...@@ -348,14 +348,8 @@ extdef:
ifobjc ifobjc
| objcdef | objcdef
end ifobjc end ifobjc
| ASM_KEYWORD '(' expr ')' ';' | ASM_KEYWORD '(' STRING ')' ';'
{ STRIP_NOPS ($3); { assemble_asm ($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 | extension extdef
{ RESTORE_WARN_FLAGS ($1); } { RESTORE_WARN_FLAGS ($1); }
; ;
...@@ -2306,20 +2300,20 @@ stmt: ...@@ -2306,20 +2300,20 @@ stmt:
| RETURN expr ';' | RETURN expr ';'
{ stmt_count++; { stmt_count++;
$$ = c_expand_return ($2); } $$ = c_expand_return ($2); }
| ASM_KEYWORD maybe_type_qual '(' expr ')' ';' | ASM_KEYWORD maybe_type_qual '(' STRING ')' ';'
{ stmt_count++; { stmt_count++;
$$ = simple_asm_stmt ($4); } $$ = simple_asm_stmt ($4); }
/* This is the case with just output operands. */ /* This is the case with just output operands. */
| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';' | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ')' ';'
{ stmt_count++; { stmt_count++;
$$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); } $$ = build_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
/* This is the case with input operands as well. */ /* This is the case with input operands as well. */
| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ':'
asm_operands ')' ';' asm_operands ')' ';'
{ stmt_count++; { stmt_count++;
$$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); } $$ = build_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
/* This is the case with clobbered registers as well. */ /* This is the case with clobbered registers as well. */
| ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' | ASM_KEYWORD maybe_type_qual '(' STRING ':' asm_operands ':'
asm_operands ':' asm_clobbers ')' ';' asm_operands ':' asm_clobbers ')' ';'
{ stmt_count++; { stmt_count++;
$$ = build_asm_stmt ($2, $4, $6, $8, $10); } $$ = build_asm_stmt ($2, $4, $6, $8, $10); }
......
...@@ -6820,27 +6820,16 @@ process_init_element (value) ...@@ -6820,27 +6820,16 @@ process_init_element (value)
/* Build a simple asm-statement, from one string literal. */ /* Build a simple asm-statement, from one string literal. */
tree tree
simple_asm_stmt (expr) simple_asm_stmt (string)
tree expr; tree string;
{ {
STRIP_NOPS (expr); tree stmt;
if (TREE_CODE (expr) == ADDR_EXPR)
expr = TREE_OPERAND (expr, 0);
if (TREE_CODE (expr) == STRING_CST) stmt = add_stmt (build_stmt (ASM_STMT, NULL_TREE, string,
{ NULL_TREE, NULL_TREE,
tree stmt; NULL_TREE));
ASM_INPUT_P (stmt) = 1;
stmt = add_stmt (build_stmt (ASM_STMT, NULL_TREE, expr, return stmt;
NULL_TREE, NULL_TREE,
NULL_TREE));
ASM_INPUT_P (stmt) = 1;
return stmt;
}
error ("argument of `asm' is not a constant string");
return NULL_TREE;
} }
/* Build an asm-statement, whose components are a CV_QUALIFIER, a /* Build an asm-statement, whose components are a CV_QUALIFIER, a
...@@ -6856,12 +6845,6 @@ build_asm_stmt (cv_qualifier, string, outputs, inputs, clobbers) ...@@ -6856,12 +6845,6 @@ build_asm_stmt (cv_qualifier, string, outputs, inputs, clobbers)
{ {
tree tail; tree tail;
if (TREE_CODE (string) != STRING_CST)
{
error ("asm template is not a string constant");
return NULL_TREE;
}
if (cv_qualifier != NULL_TREE if (cv_qualifier != NULL_TREE
&& cv_qualifier != ridpointers[(int) RID_VOLATILE]) && cv_qualifier != ridpointers[(int) RID_VOLATILE])
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment