c-common.def (FILE_STMT): New code.

* c-common.def (FILE_STMT): New code.
        * c-common.c (statement_code_p): It's a statement.
        * c-common.h (stmt_tree_s): Add x_last_filename.
        (FILE_STMT_FILENAME_NODE, FILE_STMT_FILENAME): New macros.
        (last_expr_filename): New macro.
        * c-semantics.c (begin_stmt_tree): Initialize it.
        (add_stmt): If the filename changed, also insert a
        FILE_STMT.
        (expand_stmt): Handle seeing one.

From-SVN: r48881
This commit is contained in:
Jason Merrill 2002-01-15 17:27:07 -05:00 committed by Jason Merrill
parent 93e9a99247
commit de097a2d7d
5 changed files with 53 additions and 1 deletions

View File

@ -1,3 +1,15 @@
2002-01-15 Jason Merrill <jason@redhat.com>
* c-common.def (FILE_STMT): New code.
* c-common.c (statement_code_p): It's a statement.
* c-common.h (stmt_tree_s): Add x_last_filename.
(FILE_STMT_FILENAME_NODE, FILE_STMT_FILENAME): New macros.
(last_expr_filename): New macro.
* c-semantics.c (begin_stmt_tree): Initialize it.
(add_stmt): If the filename changed, also insert a
FILE_STMT.
(expand_stmt): Handle seeing one.
2002-01-15 Eric Christopher <echristo@redhat.com>
* flow.c (propagate_one_insn): Add error message and print out

View File

@ -3111,6 +3111,7 @@ statement_code_p (code)
case GOTO_STMT:
case LABEL_STMT:
case ASM_STMT:
case FILE_STMT:
case CASE_LABEL:
return 1;

View File

@ -92,6 +92,10 @@ DEFTREECODE (ASM_STMT, "asm_stmt", 'e', 5)
variables declared in this scope. */
DEFTREECODE (SCOPE_STMT, "scope_stmt", 'e', 1)
/* A FILE_STMT marks the spot where a function changes files. It has no
other semantics. FILE_STMT_FILENAME gives the name. */
DEFTREECODE (FILE_STMT, "file_stmt", 'e', 1)
/* Used to represent a CASE_LABEL. The operands are CASE_LOW and
CASE_HIGH, respectively. If CASE_LOW is NULL_TREE, the label is a
'default' label. If CASE_HIGH is NULL_TREE, the label is a normal case
@ -108,3 +112,9 @@ DEFTREECODE (STMT_EXPR, "stmt_expr", 'e', 1)
the DECL_INITIAL of that decl is the CONSTRUCTOR that initializes
the compound literal. */
DEFTREECODE (COMPOUND_LITERAL_EXPR, "compound_literal_expr", 'e', 1)
/*
Local variables:
mode:c
End:
*/

View File

@ -257,6 +257,8 @@ struct stmt_tree_s {
/* The type of the last expression statement. (This information is
needed to implement the statement-expression extension.) */
tree x_last_expr_type;
/* The last filename we recorded. */
const char *x_last_expr_filename;
/* In C++, Non-zero if we should treat statements as full
expressions. In particular, this variable is no-zero if at the
end of a statement we should destroy any temporaries created
@ -296,6 +298,10 @@ struct language_function {
#define last_expr_type (current_stmt_tree ()->x_last_expr_type)
/* The name of the last file we have seen. */
#define last_expr_filename (current_stmt_tree ()->x_last_expr_filename)
/* LAST_TREE contains the last statement parsed. These are chained
together through the TREE_CHAIN field, but often need to be
re-organized since the parse is performed bottom-up. This macro
@ -688,6 +694,12 @@ extern tree strip_array_types PARAMS ((tree));
#define ASM_VOLATILE_P(NODE) \
(ASM_CV_QUAL (ASM_STMT_CHECK (NODE)) != NULL_TREE)
/* The filename we are changing to as of this FILE_STMT. */
#define FILE_STMT_FILENAME_NODE(NODE) \
(TREE_OPERAND (FILE_STMT_CHECK (NODE), 0))
#define FILE_STMT_FILENAME(NODE) \
(IDENTIFIER_POINTER (FILE_STMT_FILENAME_NODE (NODE)))
/* The line-number at which a statement began. But if
STMT_LINENO_FOR_FN_P does holds, then this macro gives the
line number for the end of the current function instead. */

View File

@ -60,6 +60,7 @@ begin_stmt_tree (t)
*t = build_nt (EXPR_STMT, void_zero_node);
last_tree = *t;
last_expr_type = NULL_TREE;
last_expr_filename = input_filename;
}
/* T is a statement. Add it to the statement-tree. */
@ -68,6 +69,19 @@ tree
add_stmt (t)
tree t;
{
if (input_filename != last_expr_filename)
{
/* If the filename has changed, also add in a FILE_STMT. Do a string
compare first, though, as it might be an equivalent string. */
int add = (strcmp (input_filename, last_expr_filename) != 0);
last_expr_filename = input_filename;
if (add)
{
tree pos = build_nt (FILE_STMT, get_identifier (input_filename));
add_stmt (pos);
}
}
/* Add T to the statement-tree. */
TREE_CHAIN (last_tree) = t;
last_tree = t;
@ -760,6 +774,10 @@ expand_stmt (t)
switch (TREE_CODE (t))
{
case FILE_STMT:
input_filename = FILE_STMT_FILENAME (t);
break;
case RETURN_STMT:
genrtl_return_stmt (t);
break;
@ -845,4 +863,3 @@ expand_stmt (t)
t = TREE_CHAIN (t);
}
}