aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2002-01-15 17:27:07 -0500
committerJason Merrill <jason@gcc.gnu.org>2002-01-15 17:27:07 -0500
commitde097a2d7d044caf6841fa395bb322d4ef8ba841 (patch)
tree9dec30bd55dcecc61d1bc99e776548971a77e3dd
parent93e9a9924741c257172f3384ae199b45b5364886 (diff)
downloadgcc-de097a2d7d044caf6841fa395bb322d4ef8ba841.zip
gcc-de097a2d7d044caf6841fa395bb322d4ef8ba841.tar.gz
gcc-de097a2d7d044caf6841fa395bb322d4ef8ba841.tar.bz2
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
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-common.c1
-rw-r--r--gcc/c-common.def10
-rw-r--r--gcc/c-common.h12
-rw-r--r--gcc/c-semantics.c19
5 files changed, 53 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2657044..2ae5a60 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/c-common.c b/gcc/c-common.c
index b08ef5b..bbccf4a 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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;
diff --git a/gcc/c-common.def b/gcc/c-common.def
index 2f14cf2..d59a151 100644
--- a/gcc/c-common.def
+++ b/gcc/c-common.def
@@ -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:
+*/
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 873021b..3aaa513 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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. */
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index 4bab4d3..682943f 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -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);
}
}
-