summaryrefslogtreecommitdiff
path: root/gcc/treelang
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-06 09:18:46 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-05-06 09:18:46 +0000
commit6f823f9030e4059c4b0659eb5145ac62a604ceff (patch)
tree40b598b4edfdb0e0256b7acc704bac61ff58f9e8 /gcc/treelang
parent9ebce04cdabf1ce1448cd01cded675d5ab64d7e5 (diff)
downloadgcc-6f823f9030e4059c4b0659eb5145ac62a604ceff.tar.gz
treelang:
* Make-lang.in (treelang/tree1.o): Depends on input.h (treelang/treetree.o, treelang/parse.o, treelang/lex.o): Likewise. * treelang.h: #include input.h. (in_fname): Remove. (struct token_part): Remove lineno, add location. * lex.l (next_tree_lineno): Remove. (update_lineno_charno): Adjust. (dump_lex_value): Adjust. * parse.y (variable_def, function_prototype, function, statement, if_statement, return, function_invocation, variable_ref): Adjust. (print_token, yyerror, ensure_not_void): Adjust. tree1.c (in_fname): Remove. (treelang_init): Setup input_location. (lookup_tree_name): Adjust. (insert_tree_name): Adjust. * treetree.c (tree_code_if_start): Replace filename and lineno parms with loc. Adjust. (tree_code_if_else, tree_code_if_end, tree_code_create_function_prototype, tree_code_create_function_initial, tree_code_create_function_wrapup, tree_code_create_variable, tree_code_output_expression_statement): Likewise. * treetree.h (tree_code_if_start): Replace filename and lineno parms with loc. (tree_code_if_else, tree_code_if_end, tree_code_create_function_prototype, tree_code_create_function_initial, tree_code_create_function_wrapup, tree_code_create_variable, tree_code_output_expression_statement): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@66519 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/treelang')
-rw-r--r--gcc/treelang/ChangeLog32
-rw-r--r--gcc/treelang/Make-lang.in8
-rw-r--r--gcc/treelang/lex.l16
-rw-r--r--gcc/treelang/parse.y69
-rw-r--r--gcc/treelang/tree1.c26
-rw-r--r--gcc/treelang/treelang.h7
-rw-r--r--gcc/treelang/treetree.c73
-rw-r--r--gcc/treelang/treetree.h35
8 files changed, 147 insertions, 119 deletions
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog
index 0c30bdba7e6..cd2c9c4b863 100644
--- a/gcc/treelang/ChangeLog
+++ b/gcc/treelang/ChangeLog
@@ -1,3 +1,35 @@
+2003-05-06 Nathan Sidwell <nathan@codesourcery.com>
+
+ * Make-lang.in (treelang/tree1.o): Depends on input.h
+ (treelang/treetree.o, treelang/parse.o, treelang/lex.o): Likewise.
+ * treelang.h: #include input.h.
+ (in_fname): Remove.
+ (struct token_part): Remove lineno, add location.
+ * lex.l (next_tree_lineno): Remove.
+ (update_lineno_charno): Adjust.
+ (dump_lex_value): Adjust.
+ * parse.y (variable_def, function_prototype, function, statement,
+ if_statement, return, function_invocation, variable_ref): Adjust.
+ (print_token, yyerror, ensure_not_void): Adjust.
+ tree1.c (in_fname): Remove.
+ (treelang_init): Setup input_location.
+ (lookup_tree_name): Adjust.
+ (insert_tree_name): Adjust.
+ * treetree.c (tree_code_if_start): Replace filename and lineno
+ parms with loc. Adjust.
+ (tree_code_if_else, tree_code_if_end,
+ tree_code_create_function_prototype,
+ tree_code_create_function_initial,
+ tree_code_create_function_wrapup, tree_code_create_variable,
+ tree_code_output_expression_statement): Likewise.
+ * treetree.h (tree_code_if_start): Replace filename and lineno
+ parms with loc.
+ (tree_code_if_else, tree_code_if_end,
+ tree_code_create_function_prototype,
+ tree_code_create_function_initial,
+ tree_code_create_function_wrapup, tree_code_create_variable,
+ tree_code_output_expression_statement): Likewise.
+
2003-05-01 Nathan Sidwell <nathan@codesourcery.com>
* tree1.c (treelang_init): Rename lineno to input_line.
diff --git a/gcc/treelang/Make-lang.in b/gcc/treelang/Make-lang.in
index e1d73ed8075..2e31fac8c73 100644
--- a/gcc/treelang/Make-lang.in
+++ b/gcc/treelang/Make-lang.in
@@ -96,19 +96,19 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
treelang/tree1.o: treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
flags.h toplev.h $(GGC_H) $(TREE_H) diagnostic.h treelang/treelang.h \
- treelang/treetree.h \
+ input.h treelang/treetree.h \
treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h
treelang/treetree.o: treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) flags.h output.h $(C_TREE_H) $(RTL_H) $(GGC_H) toplev.h \
- varray.h $(LANGHOOKS_DEF_H) langhooks.h treelang/treelang.h \
+ varray.h $(LANGHOOKS_DEF_H) langhooks.h treelang/treelang.h input.h \
treelang/treetree.h treelang/parse.h
treelang/parse.o: treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
- $(TM_H) diagnostic.h treelang/treelang.h treelang/treetree.h
+ $(TM_H) diagnostic.h treelang/treelang.h input.h treelang/treetree.h
treelang/lex.o: treelang/lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
- $(TM_H) diagnostic.h $(TREE_H) treelang/treelang.h treelang/parse.h
+ $(TM_H) diagnostic.h $(TREE_H) treelang/treelang.h input.h treelang/parse.h
# generated files the files from lex and yacc are put into the source
# directory in case someone wants to build but does not have
diff --git a/gcc/treelang/lex.l b/gcc/treelang/lex.l
index 293da379711..364bf0208d4 100644
--- a/gcc/treelang/lex.l
+++ b/gcc/treelang/lex.l
@@ -51,7 +51,6 @@ extern int option_lexer_trace;
int yylex (void);
void update_yylval (int a);
-static int next_tree_lineno=1;
static int next_tree_charno=1;
static void update_lineno_charno (void);
@@ -75,7 +74,7 @@ static void dump_lex_value (int lexret);
{
/* Should really allocate only what we need. lll;. */
yylval = my_malloc (sizeof (struct prod_token_parm_item));
- ((struct prod_token_parm_item *)yylval)->tp.tok.lineno = next_tree_lineno;
+ ((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
}
@@ -213,9 +212,10 @@ static void dump_lex_value (int lexret);
[^\n] {
update_lineno_charno ();
- fprintf (stderr, "%s:%i:%i: Unrecognized character %c\n", in_fname,
- ((struct prod_token_parm_item *)yylval)->tp.tok.lineno,
- ((struct prod_token_parm_item *)yylval)->tp.tok.charno, yytext[0]);
+ fprintf (stderr, "%s:%i:%i: Unrecognized character %c\n",
+ ((struct prod_token_parm_item *)yylval)->tp.tok.location.file,
+ ((struct prod_token_parm_item *)yylval)->tp.tok.location.line,
+ ((struct prod_token_parm_item *)yylval)->tp.tok.charno, yytext[0]);
errorcount++;
}
@@ -231,13 +231,13 @@ update_lineno_charno (void)
/* Update the values we send to caller in case we sometimes don't
tell them about all the 'tokens' eg comments etc. */
int yyl;
- ((struct prod_token_parm_item *)yylval)->tp.tok.lineno = next_tree_lineno;
+ ((struct prod_token_parm_item *)yylval)->tp.tok.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
for ( yyl = 0; yyl < yyleng; ++yyl )
{
if ( yytext[yyl] == '\n' )
{
- ++next_tree_lineno;
+ ++input_line;
next_tree_charno = 1;
}
else
@@ -269,7 +269,7 @@ dump_lex_value (int lexret)
{
int ix;
fprintf (stderr, " %d l:%d c:%d ln:%d text=", lexret,
- ((struct prod_token_parm_item *) yylval)->tp.tok.lineno,
+ ((struct prod_token_parm_item *) yylval)->tp.tok.location.line,
((struct prod_token_parm_item *) yylval)->tp.tok.charno,
((struct prod_token_parm_item *) yylval)->tp.tok.length);
for (ix = 0; ix < yyleng; ix++)
diff --git a/gcc/treelang/parse.y b/gcc/treelang/parse.y
index fc6256ba912..bb530f9e837 100644
--- a/gcc/treelang/parse.y
+++ b/gcc/treelang/parse.y
@@ -203,8 +203,9 @@ storage typename NAME init_opt SEMICOLON {
abort ();
if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE)
{
- fprintf (stderr, "%s:%i:%i: External reference variables may not have initial value\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: External reference variables may not have initial value\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -216,8 +217,7 @@ storage typename NAME init_opt SEMICOLON {
((struct prod_token_parm_item*)SYMBOL_TABLE_NAME (prod))->tp.tok.length,
NUMERIC_TYPE (prod),
VAR_INIT (prod)? ((struct prod_token_parm_item*)VAR_INIT (prod))->tp.pro.code:NULL,
- in_fname,
- tok->tp.tok.lineno);
+ tok->tp.tok.location);
if (!prod->tp.pro.code)
abort ();
}
@@ -277,8 +277,9 @@ storage typename NAME LEFT_PARENTHESIS parameters RIGHT_PARENTHESIS SEMICOLON {
break;
case AUTOMATIC_STORAGE:
- fprintf (stderr, "%s:%i:%i: A function cannot be automatic\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: A function cannot be automatic\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -323,8 +324,7 @@ storage typename NAME LEFT_PARENTHESIS parameters RIGHT_PARENTHESIS SEMICOLON {
prod->tp.pro.code = tree_code_create_function_prototype
(tok->tp.tok.chars, STORAGE_CLASS (prod), NUMERIC_TYPE (type),
- first_parms, in_fname, tok->tp.tok.lineno);
-
+ first_parms, tok->tp.tok.location);
}
;
@@ -340,8 +340,9 @@ NAME LEFT_BRACE {
current_function = proto = lookup_tree_name (&search_prod);
if (!proto)
{
- fprintf (stderr, "%s:%i:%i: Function prototype not found\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Function prototype not found\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -349,7 +350,7 @@ NAME LEFT_BRACE {
if (!proto->tp.pro.code)
abort ();
tree_code_create_function_initial
- (proto->tp.pro.code, in_fname, tok->tp.tok.lineno,
+ (proto->tp.pro.code, tok->tp.tok.location,
FIRST_PARMS (current_function));
/* Check all the parameters have code. */
@@ -366,7 +367,7 @@ NAME LEFT_BRACE {
variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok;
tok = $1;
- tree_code_create_function_wrapup (in_fname, tok->tp.tok.lineno);
+ tree_code_create_function_wrapup (tok->tp.tok.location);
current_function = NULL;
}
;
@@ -472,7 +473,8 @@ statement:
expression SEMICOLON {
struct prod_token_parm_item *exp;
exp = $1;
- tree_code_output_expression_statement (exp->tp.pro.code, in_fname, exp->tp.pro.main_token->tp.tok.lineno);
+ tree_code_output_expression_statement (exp->tp.pro.code,
+ exp->tp.pro.main_token->tp.tok.location);
}
|return SEMICOLON {
/* Nothing to do. */
@@ -489,7 +491,7 @@ IF LEFT_PARENTHESIS expression RIGHT_PARENTHESIS {
tok = $1;
exp = $3;
ensure_not_void (NUMERIC_TYPE (exp), exp->tp.pro.main_token);
- tree_code_if_start (exp->tp.pro.code, in_fname, tok->tp.tok.lineno);
+ tree_code_if_start (exp->tp.pro.code, tok->tp.tok.location);
}
LEFT_BRACE statements_opt RIGHT_BRACE {
/* Just let the statements flow. */
@@ -497,12 +499,12 @@ LEFT_BRACE statements_opt RIGHT_BRACE {
ELSE {
struct prod_token_parm_item* tok;
tok = $1;
- tree_code_if_else (in_fname, tok->tp.tok.lineno);
+ tree_code_if_else (tok->tp.tok.location);
}
LEFT_BRACE statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok;
tok = $12;
- tree_code_if_end (in_fname, tok->tp.tok.lineno);
+ tree_code_if_end (tok->tp.tok.location);
}
;
@@ -518,8 +520,9 @@ tl_RETURN expression_opt {
tree_code_generate_return (type_prod->tp.pro.code, NULL);
else
{
- fprintf (stderr, "%s:%i:%i: Redundant expression in return\n", in_fname,
- ret_tok->tp.tok.lineno, ret_tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Redundant expression in return\n",
+ ret_tok->tp.tok.location.file,
+ ret_tok->tp.tok.location.line, ret_tok->tp.tok.charno);
print_token (stderr, 0, ret_tok);
errorcount++;
tree_code_generate_return (type_prod->tp.pro.code, NULL);
@@ -527,8 +530,9 @@ tl_RETURN expression_opt {
else
if ($2 == NULL)
{
- fprintf (stderr, "%s:%i:%i: Expression missing in return\n", in_fname,
- ret_tok->tp.tok.lineno, ret_tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Expression missing in return\n",
+ ret_tok->tp.tok.location.file,
+ ret_tok->tp.tok.location.line, ret_tok->tp.tok.charno);
print_token (stderr, 0, ret_tok);
errorcount++;
}
@@ -636,8 +640,9 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS {
proto = lookup_tree_name (&search_prod);
if (!proto)
{
- fprintf (stderr, "%s:%i:%i: Function prototype not found\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Function prototype not found\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -654,8 +659,9 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS {
if (exp_count != exp_proto_count)
{
- fprintf (stderr, "%s:%i:%i: expression count mismatch with prototype\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: expression count mismatch with prototype\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -715,8 +721,9 @@ NAME {
symbol_table_entry = lookup_tree_name (&search_prod);
if (!symbol_table_entry)
{
- fprintf (stderr, "%s:%i:%i: Variable referred to but not defined\n", in_fname,
- tok->tp.tok.lineno, tok->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Variable referred to but not defined\n",
+ tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
@@ -766,7 +773,7 @@ print_token (FILE * file, unsigned int type ATTRIBUTE_UNUSED, YYSTYPE value)
unsigned int ix;
tok = value;
- fprintf (file, "%d \"", tok->tp.tok.lineno);
+ fprintf (file, "%d \"", tok->tp.tok.location.line);
for (ix = 0; ix < tok->tp.tok.length; ix++)
fprintf (file, "%c", tok->tp.tok.chars[ix]);
fprintf (file, "\"");
@@ -781,7 +788,8 @@ yyerror (const char *error_message)
tok = yylval;
if (tok)
{
- fprintf (stderr, "%s:%i:%i: %s\n", in_fname, tok->tp.tok.lineno, tok->tp.tok.charno, error_message);
+ fprintf (stderr, "%s:%i:%i: %s\n", tok->tp.tok.location.file,
+ tok->tp.tok.location.line, tok->tp.tok.charno, error_message);
print_token (stderr, 0, tok);
}
else
@@ -823,8 +831,9 @@ ensure_not_void (unsigned int type, struct prod_token_parm_item* name)
{
if (type == VOID)
{
- fprintf (stderr, "%s:%i:%i: Type must not be void in this context\n", in_fname,
- name->tp.tok.lineno, name->tp.tok.charno);
+ fprintf (stderr, "%s:%i:%i: Type must not be void in this context\n",
+ name->tp.tok.location.file,
+ name->tp.tok.location.line, name->tp.tok.charno);
print_token (stderr, 0, name);
errorcount++;
}
diff --git a/gcc/treelang/tree1.c b/gcc/treelang/tree1.c
index ad5622a7ddd..3a6681a9b0f 100644
--- a/gcc/treelang/tree1.c
+++ b/gcc/treelang/tree1.c
@@ -78,8 +78,6 @@ unsigned int option_lexer_trace = 0;
/* Local variables. */
-const char *in_fname; /* Input file name. */
-
/* This is 1 if we have output the version string. */
static int version_done = 0;
@@ -187,9 +185,7 @@ treelang_decode_option (num_options_left, first_option_left)
bool
treelang_init ()
{
- in_fname = main_input_filename;
-
- /* Set up the declarations needed for this front end. */
+ input_filename = main_input_filename;
input_line = 0;
/* Init decls etc. */
@@ -198,7 +194,7 @@ treelang_init ()
/* This error will not happen from GCC as it will always create a
fake input file. */
- if (!in_fname || in_fname[0] == ' ' || !in_fname[0])
+ if (!input_filename || input_filename[0] == ' ' || !input_filename[0])
{
if (!version_done)
{
@@ -209,10 +205,10 @@ treelang_init ()
return false;
}
- yyin = fopen (in_fname, "r");
+ yyin = fopen (input_filename, "r");
if (!yyin)
{
- fprintf (stderr, "Unable to open input file %s\n", in_fname);
+ fprintf (stderr, "Unable to open input file %s\n", input_filename);
exit (1);
}
@@ -279,13 +275,16 @@ lookup_tree_name (struct prod_token_parm_item *prod)
if (memcmp (tok->tp.tok.chars, this_tok->tp.tok.chars, this_tok->tp.tok.length))
continue;
if (option_parser_trace)
- fprintf (stderr, "Found symbol %s (%i:%i) as %i \n", tok->tp.tok.chars,
- tok->tp.tok.lineno, tok->tp.tok.charno, NUMERIC_TYPE (this));
+ fprintf (stderr, "Found symbol %s (%i:%i) as %i \n",
+ tok->tp.tok.chars,
+ tok->tp.tok.location.line, tok->tp.tok.charno,
+ NUMERIC_TYPE (this));
return this;
}
if (option_parser_trace)
- fprintf (stderr, "Not found symbol %s (%i:%i) as %i \n", tok->tp.tok.chars,
- tok->tp.tok.lineno, tok->tp.tok.charno, tok->type);
+ fprintf (stderr, "Not found symbol %s (%i:%i) as %i \n",
+ tok->tp.tok.chars,
+ tok->tp.tok.location.line, tok->tp.tok.charno, tok->type);
return NULL;
}
@@ -299,7 +298,8 @@ insert_tree_name (struct prod_token_parm_item *prod)
sanity_check (prod);
if (lookup_tree_name (prod))
{
- fprintf (stderr, "%s:%i:%i duplicate name %s\n", in_fname, tok->tp.tok.lineno,
+ fprintf (stderr, "%s:%i:%i duplicate name %s\n",
+ tok->tp.tok.location.file, tok->tp.tok.location.line,
tok->tp.tok.charno, tok->tp.tok.chars);
errorcount++;
return 1;
diff --git a/gcc/treelang/treelang.h b/gcc/treelang/treelang.h
index 5fded628736..abeeb1e9409 100644
--- a/gcc/treelang/treelang.h
+++ b/gcc/treelang/treelang.h
@@ -30,6 +30,8 @@
*/
+#include "input.h"
+
/* Parse structure type. */
enum category_enum
{ /* These values less likely to be there by chance unlike 0/1,
@@ -39,8 +41,7 @@ enum category_enum
parameter_category = 333
};
-/* Input file name and FILE. */
-extern const char* in_fname;
+/* Input file FILE. */
extern FILE* yyin;
/* Forward references to satisfy mutually recursive definitions. */
@@ -53,7 +54,7 @@ typedef struct GTY(()) prod_token_parm_item item;
struct token_part GTY(())
{
- unsigned int lineno;
+ location_t location;
unsigned int charno;
unsigned int length; /* The value. */
unsigned char* chars;
diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c
index e250e5b6a7b..4ff2c2fa450 100644
--- a/gcc/treelang/treetree.c
+++ b/gcc/treelang/treetree.c
@@ -178,14 +178,14 @@ tree_code_get_type (int type_num)
LINENO in file FILENAME. */
void
-tree_code_if_start (tree exp, const char* filename, int lineno)
+tree_code_if_start (tree exp, location_t loc)
{
tree cond_exp;
cond_exp = build (NE_EXPR,
TREE_TYPE (exp),
exp,
build1 (CONVERT_EXPR, TREE_TYPE (exp), integer_zero_node));
- emit_line_note (filename, lineno); /* Output the line number information. */
+ emit_line_note (loc.file, loc.line); /* Output the line number information. */
expand_start_cond (cond_exp, /* Exit-able if nonzero. */ 0);
}
@@ -193,9 +193,9 @@ tree_code_if_start (tree exp, const char* filename, int lineno)
at line LINENO in file FILENAME. */
void
-tree_code_if_else (const char* filename, int lineno)
+tree_code_if_else (location_t loc)
{
- emit_line_note (filename, lineno); /* Output the line number information. */
+ emit_line_note (loc.file, loc.line); /* Output the line number information. */
expand_start_else ();
}
@@ -203,9 +203,9 @@ tree_code_if_else (const char* filename, int lineno)
at line LINENO in file FILENAME. */
void
-tree_code_if_end (const char* filename, int lineno)
+tree_code_if_end (location_t loc)
{
- emit_line_note (filename, lineno); /* Output the line number information. */
+ emit_line_note (loc.file, loc.line); /* Output the line number information. */
expand_end_cond ();
}
@@ -215,11 +215,10 @@ tree_code_if_end (const char* filename, int lineno)
tree
tree_code_create_function_prototype (unsigned char* chars,
- unsigned int storage_class,
- unsigned int ret_type,
- struct prod_token_parm_item* parms,
- const char* filename,
- int lineno)
+ unsigned int storage_class,
+ unsigned int ret_type,
+ struct prod_token_parm_item* parms,
+ location_t loc)
{
tree id;
@@ -251,13 +250,7 @@ tree_code_create_function_prototype (unsigned char* chars,
fn_decl = build_decl (FUNCTION_DECL, id, fn_type);
DECL_CONTEXT (fn_decl) = NULL_TREE; /* Nested functions not supported here. */
- DECL_SOURCE_FILE (fn_decl) = filename;
- /* if (lineno > 1000000)
- ; */ /* Probably the line # is rubbish because someone forgot to set
- the line number - and unfortunately impossible line #s are used as
- magic flags at various times. The longest known function for
- example is about 550,000 lines (it was written in COBOL). */
- DECL_SOURCE_LINE (fn_decl) = lineno;
+ DECL_SOURCE_LOCATION (fn_decl) = loc;
TREE_USED (fn_decl) = 1;
@@ -303,9 +296,8 @@ tree_code_create_function_prototype (unsigned char* chars,
parameter details are in the lists PARMS. Returns nothing. */
void
tree_code_create_function_initial (tree prev_saved,
- const char* filename,
- int lineno,
- struct prod_token_parm_item* parms)
+ location_t loc,
+ struct prod_token_parm_item* parms)
{
tree fn_decl;
tree param_decl;
@@ -331,15 +323,14 @@ tree_code_create_function_initial (tree prev_saved,
current_function_decl = fn_decl;
DECL_INITIAL (fn_decl) = error_mark_node;
- DECL_SOURCE_FILE (fn_decl) = filename;
- DECL_SOURCE_LINE (fn_decl) = lineno;
+ DECL_SOURCE_LOCATION (fn_decl) = loc;
/* Prepare creation of rtl for a new function. */
resultdecl = DECL_RESULT (fn_decl) = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (TREE_TYPE (fn_decl)));
DECL_CONTEXT (DECL_RESULT (fn_decl)) = fn_decl;
- DECL_SOURCE_FILE (resultdecl) = filename;
- DECL_SOURCE_LINE (resultdecl) = lineno;
+ DECL_SOURCE_LOCATION (resultdecl) = loc;
+
/* Work out the size. ??? is this needed. */
layout_decl (DECL_RESULT (fn_decl), 0);
@@ -358,8 +349,7 @@ tree_code_create_function_initial (tree prev_saved,
if (!fn_decl)
abort ();
DECL_CONTEXT (parm_decl) = fn_decl;
- DECL_SOURCE_FILE (parm_decl) = filename;
- DECL_SOURCE_LINE (parm_decl) = lineno;
+ DECL_SOURCE_LOCATION (parm_decl) = loc;
parm_list = chainon (parm_decl, parm_list);
}
@@ -388,7 +378,7 @@ tree_code_create_function_initial (tree prev_saved,
make_decl_rtl (fn_decl, NULL);
/* Use filename/lineno from above. */
- init_function_start (fn_decl, filename, lineno);
+ init_function_start (fn_decl, loc.file, loc.line);
/* Create rtl for startup code of function, such as saving registers. */
@@ -434,20 +424,19 @@ tree_code_create_function_initial (tree prev_saved,
expand_start_bindings (0);
- emit_line_note (filename, lineno); /* Output the line number information. */
+ emit_line_note (loc.file, loc.line); /* Output the line number information. */
}
/* Wrapup a function contained in file FILENAME, ending at line LINENO. */
void
-tree_code_create_function_wrapup (const char* filename,
- int lineno)
+tree_code_create_function_wrapup (location_t loc)
{
tree block;
tree fn_decl;
fn_decl = current_function_decl;
- emit_line_note (filename, lineno); /* Output the line number information. */
+ emit_line_note (loc.file, loc.line); /* Output the line number information. */
/* Get completely built level from debugger symbol table. */
@@ -459,7 +448,7 @@ tree_code_create_function_wrapup (const char* filename,
/* Emit rtl for end of function. */
- expand_function_end (filename, lineno, 0);
+ expand_function_end (loc.file, loc.line, 0);
/* Pop the level. */
@@ -493,12 +482,11 @@ tree_code_create_function_wrapup (const char* filename,
tree
tree_code_create_variable (unsigned int storage_class,
- unsigned char* chars,
- unsigned int length,
- unsigned int expression_type,
- tree init,
- const char* filename,
- int lineno)
+ unsigned char* chars,
+ unsigned int length,
+ unsigned int expression_type,
+ tree init,
+ location_t loc)
{
tree var_type;
tree var_id;
@@ -530,8 +518,7 @@ tree_code_create_variable (unsigned int storage_class,
DECL_CONTEXT (var_decl) = current_function_decl;
- DECL_SOURCE_FILE (var_decl) = filename;
- DECL_SOURCE_LINE (var_decl) = lineno;
+ DECL_SOURCE_LOCATION (var_decl) = loc;
/* Set the storage mode and whether only visible in the same file. */
switch (storage_class)
@@ -612,10 +599,10 @@ tree_code_generate_return (tree type, tree exp)
void
tree_code_output_expression_statement (tree code,
- const char* filename, int lineno)
+ location_t loc)
{
/* Output the line number information. */
- emit_line_note (filename, lineno);
+ emit_line_note (loc.file, loc.line);
TREE_USED (code) = 1;
TREE_SIDE_EFFECTS (code) = 1;
expand_expr_stmt (code);
diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h
index c41dd6d5ed4..f2d6e30957f 100644
--- a/gcc/treelang/treetree.h
+++ b/gcc/treelang/treetree.h
@@ -39,27 +39,26 @@ void tree_ggc_storage_always_used (void *m);
tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree op2, tree op3);
tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
void tree_code_create_function_initial (tree prev_saved,
- const char* filename, int lineno,
- struct prod_token_parm_item* parms);
-void tree_code_create_function_wrapup (const char* filename, int lineno);
+ location_t loc,
+ struct prod_token_parm_item* parms);
+void tree_code_create_function_wrapup (location_t loc);
tree tree_code_create_function_prototype (unsigned char* chars,
- unsigned int storage_class,
- unsigned int ret_type,
- struct prod_token_parm_item* parms,
- const char* filename,
- int lineno);
+ unsigned int storage_class,
+ unsigned int ret_type,
+ struct prod_token_parm_item* parms,
+ location_t loc);
tree tree_code_create_variable (unsigned int storage_class,
- unsigned char* chars,
- unsigned int length,
- unsigned int expression_type,
- tree init,
- const char* filename,
- int lineno);
-void tree_code_output_expression_statement (tree code, const char* filename, int lineno);
+ unsigned char* chars,
+ unsigned int length,
+ unsigned int expression_type,
+ tree init,
+ location_t loc);
+void tree_code_output_expression_statement (tree code,
+ location_t loc);
tree get_type_for_numeric_type (unsigned int numeric_type);
-void tree_code_if_start (tree exp, const char* filename, int lineno);
-void tree_code_if_else (const char* filename, int lineno);
-void tree_code_if_end (const char* filename, int lineno);
+void tree_code_if_start (tree exp, location_t loc);
+void tree_code_if_else (location_t loc);
+void tree_code_if_end (location_t loc);
tree tree_code_get_type (int type_num);
void treelang_init_decl_processing (void);
void treelang_finish (void);