This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[treelang PATCH]: Use location_t for locations
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, tej at melbpc dot org dot au
- Date: Sat, 03 May 2003 20:00:40 +0100
- Subject: [treelang PATCH]: Use location_t for locations
- Organization: Codesourcery LLC
Hi,
this is a treelang specific part of my location_t reworking. It simply
starts using a location_t on treelang's internal interfaces, and
use the global input_location, rather than treelang's filename and
linenumber variables.
built & tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-05-03 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.
Index: treelang/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/Make-lang.in,v
retrieving revision 1.19
diff -c -3 -p -r1.19 Make-lang.in
*** treelang/Make-lang.in 30 Apr 2003 18:27:43 -0000 1.19
--- treelang/Make-lang.in 3 May 2003 18:17:52 -0000
*************** tree1$(exeext): treelang/tree1.o treelan
*** 96,114 ****
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 \
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 \
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
treelang/lex.o: treelang/lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
! $(TM_H) diagnostic.h $(TREE_H) treelang/treelang.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
--- 96,114 ----
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 \
! 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 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 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 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
Index: treelang/lex.l
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/lex.l,v
retrieving revision 1.6
diff -c -3 -p -r1.6 lex.l
*** treelang/lex.l 1 Mar 2003 12:03:50 -0000 1.6
--- treelang/lex.l 3 May 2003 18:17:52 -0000
*************** extern int option_lexer_trace;
*** 51,57 ****
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);
--- 51,56 ----
*************** static void dump_lex_value (int lexret);
*** 75,81 ****
{
/* 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.charno = next_tree_charno;
}
--- 74,80 ----
{
/* 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.location = input_location;
((struct prod_token_parm_item *)yylval)->tp.tok.charno = next_tree_charno;
}
*************** static void dump_lex_value (int lexret);
*** 213,221 ****
[^\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]);
errorcount++;
}
--- 212,221 ----
[^\n] {
update_lineno_charno ();
! 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++;
}
*************** update_lineno_charno (void)
*** 231,243 ****
/* 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.charno = next_tree_charno;
for ( yyl = 0; yyl < yyleng; ++yyl )
{
if ( yytext[yyl] == '\n' )
{
! ++next_tree_lineno;
next_tree_charno = 1;
}
else
--- 231,243 ----
/* 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.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' )
{
! ++input_line;
next_tree_charno = 1;
}
else
*************** dump_lex_value (int lexret)
*** 269,275 ****
{
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.charno,
((struct prod_token_parm_item *) yylval)->tp.tok.length);
for (ix = 0; ix < yyleng; ix++)
--- 269,275 ----
{
int ix;
fprintf (stderr, " %d l:%d c:%d ln:%d text=", lexret,
! ((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++)
Index: treelang/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/parse.y,v
retrieving revision 1.7
diff -c -3 -p -r1.7 parse.y
*** treelang/parse.y 30 Apr 2003 19:08:12 -0000 1.7
--- treelang/parse.y 3 May 2003 18:17:54 -0000
*************** storage typename NAME init_opt SEMICOLON
*** 203,210 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 203,211 ----
abort ();
if (STORAGE_CLASS (prod) == EXTERNAL_REFERENCE_STORAGE)
{
! 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;
*************** storage typename NAME init_opt SEMICOLON
*** 216,223 ****
((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);
if (!prod->tp.pro.code)
abort ();
}
--- 217,223 ----
((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,
! tok->tp.tok.location);
if (!prod->tp.pro.code)
abort ();
}
*************** storage typename NAME LEFT_PARENTHESIS p
*** 277,284 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 277,285 ----
break;
case AUTOMATIC_STORAGE:
! 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;
*************** storage typename NAME LEFT_PARENTHESIS p
*** 323,330 ****
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);
!
}
;
--- 324,330 ----
prod->tp.pro.code = tree_code_create_function_prototype
(tok->tp.tok.chars, STORAGE_CLASS (prod), NUMERIC_TYPE (type),
! first_parms, tok->tp.tok.location);
}
;
*************** NAME LEFT_BRACE {
*** 340,347 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 340,348 ----
current_function = proto = lookup_tree_name (&search_prod);
if (!proto)
{
! 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;
*************** NAME LEFT_BRACE {
*** 349,355 ****
if (!proto->tp.pro.code)
abort ();
tree_code_create_function_initial
! (proto->tp.pro.code, in_fname, tok->tp.tok.lineno,
FIRST_PARMS (current_function));
/* Check all the parameters have code. */
--- 350,356 ----
if (!proto->tp.pro.code)
abort ();
tree_code_create_function_initial
! (proto->tp.pro.code, tok->tp.tok.location,
FIRST_PARMS (current_function));
/* Check all the parameters have code. */
*************** NAME LEFT_BRACE {
*** 366,372 ****
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);
current_function = NULL;
}
;
--- 367,373 ----
variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok;
tok = $1;
! tree_code_create_function_wrapup (tok->tp.tok.location);
current_function = NULL;
}
;
*************** statement:
*** 472,478 ****
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);
}
|return SEMICOLON {
/* Nothing to do. */
--- 473,480 ----
expression SEMICOLON {
struct prod_token_parm_item *exp;
exp = $1;
! tree_code_output_expression_statement (exp->tp.pro.code,
! exp->tp.pro.main_token->tp.tok.location);
}
|return SEMICOLON {
/* Nothing to do. */
*************** IF LEFT_PARENTHESIS expression RIGHT_PAR
*** 489,495 ****
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);
}
LEFT_BRACE statements_opt RIGHT_BRACE {
/* Just let the statements flow. */
--- 491,497 ----
tok = $1;
exp = $3;
ensure_not_void (NUMERIC_TYPE (exp), exp->tp.pro.main_token);
! tree_code_if_start (exp->tp.pro.code, tok->tp.tok.location);
}
LEFT_BRACE statements_opt RIGHT_BRACE {
/* Just let the statements flow. */
*************** LEFT_BRACE statements_opt RIGHT_BRACE {
*** 497,508 ****
ELSE {
struct prod_token_parm_item* tok;
tok = $1;
! tree_code_if_else (in_fname, tok->tp.tok.lineno);
}
LEFT_BRACE statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok;
tok = $12;
! tree_code_if_end (in_fname, tok->tp.tok.lineno);
}
;
--- 499,510 ----
ELSE {
struct prod_token_parm_item* tok;
tok = $1;
! 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 (tok->tp.tok.location);
}
;
*************** tl_RETURN expression_opt {
*** 518,525 ****
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);
print_token (stderr, 0, ret_tok);
errorcount++;
tree_code_generate_return (type_prod->tp.pro.code, NULL);
--- 520,528 ----
tree_code_generate_return (type_prod->tp.pro.code, NULL);
else
{
! 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);
*************** tl_RETURN expression_opt {
*** 527,534 ****
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);
print_token (stderr, 0, ret_tok);
errorcount++;
}
--- 530,538 ----
else
if ($2 == NULL)
{
! 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++;
}
*************** NAME LEFT_PARENTHESIS expressions_with_c
*** 636,643 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 640,648 ----
proto = lookup_tree_name (&search_prod);
if (!proto)
{
! 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;
*************** NAME LEFT_PARENTHESIS expressions_with_c
*** 654,661 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 659,667 ----
if (exp_count != exp_proto_count)
{
! 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;
*************** NAME {
*** 715,722 ****
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);
print_token (stderr, 0, tok);
errorcount++;
YYERROR;
--- 721,729 ----
symbol_table_entry = lookup_tree_name (&search_prod);
if (!symbol_table_entry)
{
! 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;
*************** print_token (FILE * file, unsigned int t
*** 766,772 ****
unsigned int ix;
tok = value;
! fprintf (file, "%d \"", tok->tp.tok.lineno);
for (ix = 0; ix < tok->tp.tok.length; ix++)
fprintf (file, "%c", tok->tp.tok.chars[ix]);
fprintf (file, "\"");
--- 773,779 ----
unsigned int ix;
tok = value;
! 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, "\"");
*************** yyerror (const char *error_message)
*** 781,787 ****
tok = yylval;
if (tok)
{
! fprintf (stderr, "%s:%i:%i: %s\n", in_fname, tok->tp.tok.lineno, tok->tp.tok.charno, error_message);
print_token (stderr, 0, tok);
}
else
--- 788,795 ----
tok = yylval;
if (tok)
{
! 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
*************** ensure_not_void (unsigned int type, stru
*** 823,830 ****
{
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);
print_token (stderr, 0, name);
errorcount++;
}
--- 831,839 ----
{
if (type == VOID)
{
! 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++;
}
Index: treelang/tree1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/tree1.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 tree1.c
*** treelang/tree1.c 1 May 2003 16:13:35 -0000 1.7
--- treelang/tree1.c 3 May 2003 18:17:55 -0000
*************** unsigned int option_lexer_trace = 0;
*** 78,85 ****
/* Local variables. */
- const char *in_fname; /* Input file name. */
-
/* This is 1 if we have output the version string. */
static int version_done = 0;
--- 78,83 ----
*************** treelang_decode_option (num_options_left
*** 187,195 ****
bool
treelang_init ()
{
! in_fname = main_input_filename;
!
! /* Set up the declarations needed for this front end. */
input_line = 0;
/* Init decls etc. */
--- 185,191 ----
bool
treelang_init ()
{
! input_filename = main_input_filename;
input_line = 0;
/* Init decls etc. */
*************** treelang_init ()
*** 198,204 ****
/* 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 (!version_done)
{
--- 194,200 ----
/* This error will not happen from GCC as it will always create a
fake input file. */
! if (!input_filename || input_filename[0] == ' ' || !input_filename[0])
{
if (!version_done)
{
*************** treelang_init ()
*** 209,218 ****
return false;
}
! yyin = fopen (in_fname, "r");
if (!yyin)
{
! fprintf (stderr, "Unable to open input file %s\n", in_fname);
exit (1);
}
--- 205,214 ----
return false;
}
! yyin = fopen (input_filename, "r");
if (!yyin)
{
! fprintf (stderr, "Unable to open input file %s\n", input_filename);
exit (1);
}
*************** lookup_tree_name (struct prod_token_parm
*** 279,291 ****
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));
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);
return NULL;
}
--- 275,290 ----
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.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.location.line, tok->tp.tok.charno, tok->type);
return NULL;
}
*************** insert_tree_name (struct prod_token_parm
*** 299,305 ****
sanity_check (prod);
if (lookup_tree_name (prod))
{
! fprintf (stderr, "%s:%i:%i duplicate name %s\n", in_fname, tok->tp.tok.lineno,
tok->tp.tok.charno, tok->tp.tok.chars);
errorcount++;
return 1;
--- 298,305 ----
sanity_check (prod);
if (lookup_tree_name (prod))
{
! 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;
Index: treelang/treelang.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treelang.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 treelang.h
*** treelang/treelang.h 8 Mar 2003 21:12:26 -0000 1.4
--- treelang/treelang.h 3 May 2003 18:17:55 -0000
***************
*** 30,35 ****
--- 30,37 ----
*/
+ #include "input.h"
+
/* Parse structure type. */
enum category_enum
{ /* These values less likely to be there by chance unlike 0/1,
*************** enum category_enum
*** 39,46 ****
parameter_category = 333
};
! /* Input file name and FILE. */
! extern const char* in_fname;
extern FILE* yyin;
/* Forward references to satisfy mutually recursive definitions. */
--- 41,47 ----
parameter_category = 333
};
! /* Input file FILE. */
extern FILE* yyin;
/* Forward references to satisfy mutually recursive definitions. */
*************** typedef struct GTY(()) prod_token_parm_i
*** 53,59 ****
struct token_part GTY(())
{
! unsigned int lineno;
unsigned int charno;
unsigned int length; /* The value. */
unsigned char* chars;
--- 54,60 ----
struct token_part GTY(())
{
! location_t location;
unsigned int charno;
unsigned int length; /* The value. */
unsigned char* chars;
Index: treelang/treetree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.c,v
retrieving revision 1.19
diff -c -3 -p -r1.19 treetree.c
*** treelang/treetree.c 30 Apr 2003 18:27:43 -0000 1.19
--- treelang/treetree.c 3 May 2003 18:17:57 -0000
*************** tree_code_get_type (int type_num)
*** 178,191 ****
LINENO in file FILENAME. */
void
! tree_code_if_start (tree exp, const char* filename, int lineno)
{
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. */
expand_start_cond (cond_exp, /* Exit-able if nonzero. */ 0);
}
--- 178,191 ----
LINENO in file FILENAME. */
void
! 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 (loc.file, loc.line); /* Output the line number information. */
expand_start_cond (cond_exp, /* Exit-able if nonzero. */ 0);
}
*************** tree_code_if_start (tree exp, const char
*** 193,201 ****
at line LINENO in file FILENAME. */
void
! tree_code_if_else (const char* filename, int lineno)
{
! emit_line_note (filename, lineno); /* Output the line number information. */
expand_start_else ();
}
--- 193,201 ----
at line LINENO in file FILENAME. */
void
! tree_code_if_else (location_t loc)
{
! emit_line_note (loc.file, loc.line); /* Output the line number information. */
expand_start_else ();
}
*************** tree_code_if_else (const char* filename,
*** 203,211 ****
at line LINENO in file FILENAME. */
void
! tree_code_if_end (const char* filename, int lineno)
{
! emit_line_note (filename, lineno); /* Output the line number information. */
expand_end_cond ();
}
--- 203,211 ----
at line LINENO in file FILENAME. */
void
! tree_code_if_end (location_t loc)
{
! emit_line_note (loc.file, loc.line); /* Output the line number information. */
expand_end_cond ();
}
*************** tree_code_if_end (const char* filename,
*** 215,225 ****
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)
{
tree id;
--- 215,224 ----
tree
tree_code_create_function_prototype (unsigned char* chars,
! unsigned int storage_class,
! unsigned int ret_type,
! struct prod_token_parm_item* parms,
! location_t loc)
{
tree id;
*************** tree_code_create_function_prototype (uns
*** 251,263 ****
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;
TREE_USED (fn_decl) = 1;
--- 250,256 ----
fn_decl = build_decl (FUNCTION_DECL, id, fn_type);
DECL_CONTEXT (fn_decl) = NULL_TREE; /* Nested functions not supported here. */
! DECL_SOURCE_LOCATION (fn_decl) = loc;
TREE_USED (fn_decl) = 1;
*************** tree_code_create_function_prototype (uns
*** 303,311 ****
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)
{
tree fn_decl;
tree param_decl;
--- 296,303 ----
parameter details are in the lists PARMS. Returns nothing. */
void
tree_code_create_function_initial (tree prev_saved,
! location_t loc,
! struct prod_token_parm_item* parms)
{
tree fn_decl;
tree param_decl;
*************** tree_code_create_function_initial (tree
*** 331,345 ****
current_function_decl = fn_decl;
DECL_INITIAL (fn_decl) = error_mark_node;
! DECL_SOURCE_FILE (fn_decl) = filename;
! DECL_SOURCE_LINE (fn_decl) = lineno;
/* 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;
/* Work out the size. ??? is this needed. */
layout_decl (DECL_RESULT (fn_decl), 0);
--- 323,336 ----
current_function_decl = fn_decl;
DECL_INITIAL (fn_decl) = error_mark_node;
! 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_LOCATION (resultdecl) = loc;
!
/* Work out the size. ??? is this needed. */
layout_decl (DECL_RESULT (fn_decl), 0);
*************** tree_code_create_function_initial (tree
*** 358,365 ****
if (!fn_decl)
abort ();
DECL_CONTEXT (parm_decl) = fn_decl;
! DECL_SOURCE_FILE (parm_decl) = filename;
! DECL_SOURCE_LINE (parm_decl) = lineno;
parm_list = chainon (parm_decl, parm_list);
}
--- 349,355 ----
if (!fn_decl)
abort ();
DECL_CONTEXT (parm_decl) = fn_decl;
! DECL_SOURCE_LOCATION (parm_decl) = loc;
parm_list = chainon (parm_decl, parm_list);
}
*************** tree_code_create_function_initial (tree
*** 388,394 ****
make_decl_rtl (fn_decl, NULL);
/* Use filename/lineno from above. */
! init_function_start (fn_decl, filename, lineno);
/* Create rtl for startup code of function, such as saving registers. */
--- 378,384 ----
make_decl_rtl (fn_decl, NULL);
/* Use filename/lineno from above. */
! init_function_start (fn_decl, loc.file, loc.line);
/* Create rtl for startup code of function, such as saving registers. */
*************** tree_code_create_function_initial (tree
*** 434,453 ****
expand_start_bindings (0);
! emit_line_note (filename, lineno); /* 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 block;
tree fn_decl;
fn_decl = current_function_decl;
! emit_line_note (filename, lineno); /* Output the line number information. */
/* Get completely built level from debugger symbol table. */
--- 424,442 ----
expand_start_bindings (0);
! 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 (location_t loc)
{
tree block;
tree fn_decl;
fn_decl = current_function_decl;
! emit_line_note (loc.file, loc.line); /* Output the line number information. */
/* Get completely built level from debugger symbol table. */
*************** tree_code_create_function_wrapup (const
*** 459,465 ****
/* Emit rtl for end of function. */
! expand_function_end (filename, lineno, 0);
/* Pop the level. */
--- 448,454 ----
/* Emit rtl for end of function. */
! expand_function_end (loc.file, loc.line, 0);
/* Pop the level. */
*************** tree_code_create_function_wrapup (const
*** 493,504 ****
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)
{
tree var_type;
tree var_id;
--- 482,492 ----
tree
tree_code_create_variable (unsigned int storage_class,
! unsigned char* chars,
! unsigned int length,
! unsigned int expression_type,
! tree init,
! location_t loc)
{
tree var_type;
tree var_id;
*************** tree_code_create_variable (unsigned int
*** 530,537 ****
DECL_CONTEXT (var_decl) = current_function_decl;
! DECL_SOURCE_FILE (var_decl) = filename;
! DECL_SOURCE_LINE (var_decl) = lineno;
/* Set the storage mode and whether only visible in the same file. */
switch (storage_class)
--- 518,524 ----
DECL_CONTEXT (var_decl) = current_function_decl;
! DECL_SOURCE_LOCATION (var_decl) = loc;
/* Set the storage mode and whether only visible in the same file. */
switch (storage_class)
*************** tree_code_generate_return (tree type, tr
*** 612,621 ****
void
tree_code_output_expression_statement (tree code,
! const char* filename, int lineno)
{
/* Output the line number information. */
! emit_line_note (filename, lineno);
TREE_USED (code) = 1;
TREE_SIDE_EFFECTS (code) = 1;
expand_expr_stmt (code);
--- 599,608 ----
void
tree_code_output_expression_statement (tree code,
! location_t loc)
{
/* Output the line number information. */
! emit_line_note (loc.file, loc.line);
TREE_USED (code) = 1;
TREE_SIDE_EFFECTS (code) = 1;
expand_expr_stmt (code);
Index: treelang/treetree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.h,v
retrieving revision 1.4
diff -c -3 -p -r1.4 treetree.h
*** treelang/treetree.h 8 Mar 2003 21:12:26 -0000 1.4
--- treelang/treetree.h 3 May 2003 18:17:57 -0000
*************** void tree_ggc_storage_always_used (void
*** 39,65 ****
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);
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);
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);
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);
tree tree_code_get_type (int type_num);
void treelang_init_decl_processing (void);
void treelang_finish (void);
--- 39,64 ----
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,
! 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,
! location_t loc);
tree tree_code_create_variable (unsigned int storage_class,
! 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, 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);