class.c (finish_struct): Use location_t and input_location directly.

* class.c (finish_struct): Use location_t and input_location
	directly.
	* decl.c (make_label_decl): Likewise.
	(use_label): Likewise.
	* decl2.c (warn_if_unknown_interface): Likewise.
	(start_static_initialization_or_destruction): Likewise.
	(generate_ctor_or_dtor_function): Likewise.
	(finish_file): Likewise.
	* error.c (print_instantiation_full_context): Likewise.
	* init.c (create_temporary_var): Likewise.
	* method.c (synthesize_method): Likewise.
	* parser.c (cp_token): Likewise.
	(cp_lexer_set_source_position_from_token): Likewise.
	(cp_lexer_get_preprocessor_token): Likewise.
	(cp_parser_statement): Likewise.
	* pt.c (tsubst_friend_function): Likewise.
	(instantiate_class_template): Likewise.
	(tsubst_decl): Likewise.
	(tsubst): Likewise.
	(instantiate_decl): Likewise.
	* semantics.c (begin_class_definition): Likewise.
	(expand_body): Likewise.

From-SVN: r66423
This commit is contained in:
Nathan Sidwell 2003-05-03 11:37:22 +00:00 committed by Nathan Sidwell
parent 778ea5199f
commit 82a98427a9
10 changed files with 83 additions and 98 deletions

View File

@ -1,3 +1,28 @@
2003-05-03 Nathan Sidwell <nathan@codesourcery.com>
* class.c (finish_struct): Use location_t and input_location
directly.
* decl.c (make_label_decl): Likewise.
(use_label): Likewise.
* decl2.c (warn_if_unknown_interface): Likewise.
(start_static_initialization_or_destruction): Likewise.
(generate_ctor_or_dtor_function): Likewise.
(finish_file): Likewise.
* error.c (print_instantiation_full_context): Likewise.
* init.c (create_temporary_var): Likewise.
* method.c (synthesize_method): Likewise.
* parser.c (cp_token): Likewise.
(cp_lexer_set_source_position_from_token): Likewise.
(cp_lexer_get_preprocessor_token): Likewise.
(cp_parser_statement): Likewise.
* pt.c (tsubst_friend_function): Likewise.
(instantiate_class_template): Likewise.
(tsubst_decl): Likewise.
(tsubst): Likewise.
(instantiate_decl): Likewise.
* semantics.c (begin_class_definition): Likewise.
(expand_body): Likewise.
2003-05-01 Nathan Sidwell <nathan@codesourcery.com> 2003-05-01 Nathan Sidwell <nathan@codesourcery.com>
* class.c (finish_struct): Rename lineno to input_line. * class.c (finish_struct): Rename lineno to input_line.

View File

@ -5251,8 +5251,7 @@ unreverse_member_declarations (tree t)
tree tree
finish_struct (tree t, tree attributes) finish_struct (tree t, tree attributes)
{ {
const char *saved_filename = input_filename; location_t saved_loc = input_location;
int saved_lineno = input_line;
/* Now that we've got all the field declarations, reverse everything /* Now that we've got all the field declarations, reverse everything
as necessary. */ as necessary. */
@ -5262,8 +5261,7 @@ finish_struct (tree t, tree attributes)
/* Nadger the current location so that diagnostics point to the start of /* Nadger the current location so that diagnostics point to the start of
the struct, not the end. */ the struct, not the end. */
input_filename = DECL_SOURCE_FILE (TYPE_NAME (t)); input_location = DECL_SOURCE_LOCATION (TYPE_NAME (t));
input_line = DECL_SOURCE_LINE (TYPE_NAME (t));
if (processing_template_decl) if (processing_template_decl)
{ {
@ -5273,8 +5271,7 @@ finish_struct (tree t, tree attributes)
else else
finish_struct_1 (t); finish_struct_1 (t);
input_filename = saved_filename; input_location = saved_loc;
input_line = saved_lineno;
TYPE_BEING_DEFINED (t) = 0; TYPE_BEING_DEFINED (t) = 0;

View File

@ -4598,8 +4598,7 @@ make_label_decl (tree id, int local_p)
/* Say where one reference is to the label, for the sake of the /* Say where one reference is to the label, for the sake of the
error if it is not defined. */ error if it is not defined. */
DECL_SOURCE_LINE (decl) = input_line; DECL_SOURCE_LOCATION (decl) = input_location;
DECL_SOURCE_FILE (decl) = input_filename;
/* Record the fact that this identifier is bound to this label. */ /* Record the fact that this identifier is bound to this label. */
SET_IDENTIFIER_LABEL_VALUE (id, decl); SET_IDENTIFIER_LABEL_VALUE (id, decl);
@ -4625,8 +4624,7 @@ use_label (tree decl)
new_ent->label_decl = decl; new_ent->label_decl = decl;
new_ent->names_in_scope = current_binding_level->names; new_ent->names_in_scope = current_binding_level->names;
new_ent->binding_level = current_binding_level; new_ent->binding_level = current_binding_level;
new_ent->o_goto_locus.line = input_line; new_ent->o_goto_locus = input_location;
new_ent->o_goto_locus.file = input_filename;
new_ent->next = named_label_uses; new_ent->next = named_label_uses;
named_label_uses = new_ent; named_label_uses = new_ent;
} }

View File

@ -178,8 +178,7 @@ warn_if_unknown_interface (tree decl)
if (flag_alt_external_templates) if (flag_alt_external_templates)
{ {
tree til = tinst_for_decl (); tree til = tinst_for_decl ();
int sl = input_line; location_t saved_loc = input_location;
const char *sf = input_filename;
if (til) if (til)
{ {
@ -188,8 +187,7 @@ warn_if_unknown_interface (tree decl)
} }
warning ("template `%#D' instantiated in file without #pragma interface", warning ("template `%#D' instantiated in file without #pragma interface",
decl); decl);
input_line = sl; input_location = saved_loc;
input_filename = sf;
} }
else else
cp_warning_at ("template `%#D' defined in file without #pragma interface", cp_warning_at ("template `%#D' defined in file without #pragma interface",
@ -2233,8 +2231,7 @@ start_static_initialization_or_destruction (tree decl, int initp)
where DECL was declared so that error-messages make sense, and so where DECL was declared so that error-messages make sense, and so
that the debugger will show somewhat sensible file and line that the debugger will show somewhat sensible file and line
information. */ information. */
input_filename = DECL_SOURCE_FILE (decl); input_location = DECL_SOURCE_LOCATION (decl);
input_line = DECL_SOURCE_LINE (decl);
/* Because of: /* Because of:
@ -2474,8 +2471,8 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority,
tree body; tree body;
size_t i; size_t i;
input_filename = locus->file; input_location = *locus;
input_line = locus->line++; locus->line++;
/* We use `I' to indicate initialization and `D' to indicate /* We use `I' to indicate initialization and `D' to indicate
destruction. */ destruction. */
@ -2554,8 +2551,7 @@ finish_file ()
location_t locus; location_t locus;
unsigned ssdf_count = 0; unsigned ssdf_count = 0;
locus.file = input_filename; locus = input_location;
locus.line = input_line;
at_eof = 1; at_eof = 1;
/* Bad parse errors. Just forget about it. */ /* Bad parse errors. Just forget about it. */
@ -2686,8 +2682,7 @@ finish_file ()
/* Set the line and file, so that it is obviously not from /* Set the line and file, so that it is obviously not from
the source file. */ the source file. */
input_filename = locus.file; input_location = locus;
input_line = locus.line;
ssdf_body = start_static_storage_duration_function (ssdf_count); ssdf_body = start_static_storage_duration_function (ssdf_count);
/* Make sure the back end knows about all the variables. */ /* Make sure the back end knows about all the variables. */
@ -2715,8 +2710,7 @@ finish_file ()
/* Finish up the static storage duration function for this /* Finish up the static storage duration function for this
round. */ round. */
input_filename = locus.file; input_location = locus;
input_line = locus.line;
finish_static_storage_duration_function (ssdf_body); finish_static_storage_duration_function (ssdf_body);
/* All those initializations and finalizations might cause /* All those initializations and finalizations might cause
@ -2905,8 +2899,7 @@ finish_file ()
dump_tree_statistics (); dump_tree_statistics ();
dump_time_statistics (); dump_time_statistics ();
} }
input_filename = locus.file; input_location = locus;
input_line = locus.line;
} }
/* T is the parse tree for an expression. Return the expression after /* T is the parse tree for an expression. Return the expression after

View File

@ -2406,9 +2406,8 @@ static void
print_instantiation_full_context (diagnostic_context *context) print_instantiation_full_context (diagnostic_context *context)
{ {
tree p = current_instantiation (); tree p = current_instantiation ();
int line = input_line; location_t location = input_location;
const char *file = input_filename;
if (p) if (p)
{ {
if (current_function_decl != TINST_DECL (p) if (current_function_decl != TINST_DECL (p)
@ -2423,17 +2422,18 @@ print_instantiation_full_context (diagnostic_context *context)
/* Avoid redundancy with the the "In function" line. */; /* Avoid redundancy with the the "In function" line. */;
else else
output_verbatim (&context->buffer, output_verbatim (&context->buffer,
"%s: In instantiation of `%s':\n", file, "%s: In instantiation of `%s':\n", location.file,
decl_as_string (TINST_DECL (p), decl_as_string (TINST_DECL (p),
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
line = TINST_LINE (p); location.line = TINST_LINE (p);
file = TINST_FILE (p); location.file = TINST_FILE (p);
p = TREE_CHAIN (p); p = TREE_CHAIN (p);
} }
} }
print_instantiation_partial_context (context, p, file, line); print_instantiation_partial_context (context, p,
location.file, location.line);
} }
/* Same as above but less verbose. */ /* Same as above but less verbose. */

View File

@ -2675,8 +2675,7 @@ create_temporary_var (type)
decl = build_decl (VAR_DECL, NULL_TREE, type); decl = build_decl (VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1; TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1; DECL_ARTIFICIAL (decl) = 1;
DECL_SOURCE_FILE (decl) = input_filename; DECL_SOURCE_LOCATION (decl) = input_location;
DECL_SOURCE_LINE (decl) = input_line;
DECL_IGNORED_P (decl) = 1; DECL_IGNORED_P (decl) = 1;
DECL_CONTEXT (decl) = current_function_decl; DECL_CONTEXT (decl) = current_function_decl;

View File

@ -754,8 +754,7 @@ synthesize_method (tree fndecl)
where the attempt to generate the function occurs, giving the where the attempt to generate the function occurs, giving the
user a hint as to why we are attempting to generate the user a hint as to why we are attempting to generate the
function. */ function. */
DECL_SOURCE_LINE (fndecl) = input_line; DECL_SOURCE_LOCATION (fndecl) = input_location;
DECL_SOURCE_FILE (fndecl) = input_filename;
interface_unknown = 1; interface_unknown = 1;
start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED); start_function (NULL_TREE, fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);

View File

@ -74,10 +74,8 @@ typedef struct cp_token GTY (())
/* If this token is a keyword, this value indicates which keyword. /* If this token is a keyword, this value indicates which keyword.
Otherwise, this value is RID_MAX. */ Otherwise, this value is RID_MAX. */
enum rid keyword; enum rid keyword;
/* The file in which this token was found. */ /* The location at which this token was found. */
const char *file_name; location_t location;
/* The line at which this token was found. */
int line_number;
} cp_token; } cp_token;
/* The number of tokens in a single token block. */ /* The number of tokens in a single token block. */
@ -406,10 +404,7 @@ cp_lexer_set_source_position_from_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
/* Update the line number. */ /* Update the line number. */
if (token->type != CPP_EOF) if (token->type != CPP_EOF)
{ input_location = token->location;
input_line = token->line_number;
input_filename = token->file_name;
}
} }
/* TOKEN points into the circular token buffer. Return a pointer to /* TOKEN points into the circular token buffer. Return a pointer to
@ -621,8 +616,8 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
if (lexer != NULL && !lexer->main_lexer_p) if (lexer != NULL && !lexer->main_lexer_p)
{ {
token->type = CPP_EOF; token->type = CPP_EOF;
token->line_number = 0; token->location.line = 0;
token->file_name = NULL; token->location.file = NULL;
token->value = NULL_TREE; token->value = NULL_TREE;
token->keyword = RID_MAX; token->keyword = RID_MAX;
@ -651,8 +646,7 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
} }
} }
/* Now we've got our token. */ /* Now we've got our token. */
token->line_number = input_line; token->location = input_location;
token->file_name = input_filename;
/* Check to see if this token is a keyword. */ /* Check to see if this token is a keyword. */
if (token->type == CPP_NAME if (token->type == CPP_NAME
@ -5591,7 +5585,7 @@ cp_parser_statement (cp_parser* parser)
/* Peek at the next token. */ /* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer); token = cp_lexer_peek_token (parser->lexer);
/* Remember the line number of the first token in the statement. */ /* Remember the line number of the first token in the statement. */
statement_line_number = token->line_number; statement_line_number = token->location.line;
/* If this is a keyword, then that will often determine what kind of /* If this is a keyword, then that will often determine what kind of
statement we have. */ statement we have. */
if (token->type == CPP_KEYWORD) if (token->type == CPP_KEYWORD)

View File

@ -4861,11 +4861,9 @@ tsubst_friend_function (decl, args)
tree args; tree args;
{ {
tree new_friend; tree new_friend;
int line = input_line; location_t saved_loc = input_location;
const char *file = input_filename;
input_line = DECL_SOURCE_LINE (decl); input_location = DECL_SOURCE_LOCATION (decl);
input_filename = DECL_SOURCE_FILE (decl);
if (TREE_CODE (decl) == FUNCTION_DECL if (TREE_CODE (decl) == FUNCTION_DECL
&& DECL_TEMPLATE_INSTANTIATION (decl) && DECL_TEMPLATE_INSTANTIATION (decl)
@ -5072,8 +5070,7 @@ tsubst_friend_function (decl, args)
} }
done: done:
input_line = line; input_location = saved_loc;
input_filename = file;
return new_friend; return new_friend;
} }
@ -5436,8 +5433,7 @@ instantiate_class_template (type)
assist in error message reporting. Since we assist in error message reporting. Since we
called push_tinst_level above, we don't need to called push_tinst_level above, we don't need to
restore these. */ restore these. */
input_line = DECL_SOURCE_LINE (t); input_location = DECL_SOURCE_LOCATION (t);
input_filename = DECL_SOURCE_FILE (t);
r = tsubst (t, args, tf_error | tf_warning, NULL_TREE); r = tsubst (t, args, tf_error | tf_warning, NULL_TREE);
if (TREE_CODE (r) == VAR_DECL) if (TREE_CODE (r) == VAR_DECL)
@ -5539,9 +5535,8 @@ instantiate_class_template (type)
implicit functions at a predictable point, and the same point implicit functions at a predictable point, and the same point
that would be used for non-template classes. */ that would be used for non-template classes. */
typedecl = TYPE_MAIN_DECL (type); typedecl = TYPE_MAIN_DECL (type);
input_line = DECL_SOURCE_LINE (typedecl); input_location = DECL_SOURCE_LOCATION (typedecl);
input_filename = DECL_SOURCE_FILE (typedecl);
unreverse_member_declarations (type); unreverse_member_declarations (type);
finish_struct_1 (type); finish_struct_1 (type);
CLASSTYPE_GOT_SEMICOLON (type) = 1; CLASSTYPE_GOT_SEMICOLON (type) = 1;
@ -5878,16 +5873,13 @@ tsubst_decl (t, args, type, complain)
tree type; tree type;
tsubst_flags_t complain; tsubst_flags_t complain;
{ {
int saved_lineno; location_t saved_loc;
const char *saved_filename;
tree r = NULL_TREE; tree r = NULL_TREE;
tree in_decl = t; tree in_decl = t;
/* Set the filename and linenumber to improve error-reporting. */ /* Set the filename and linenumber to improve error-reporting. */
saved_lineno = input_line; saved_loc = input_location;
saved_filename = input_filename; input_location = DECL_SOURCE_LOCATION (t);
input_line = DECL_SOURCE_LINE (t);
input_filename = DECL_SOURCE_FILE (t);
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
@ -6353,8 +6345,7 @@ tsubst_decl (t, args, type, complain)
} }
/* Restore the file and line information. */ /* Restore the file and line information. */
input_line = saved_lineno; input_location = saved_loc;
input_filename = saved_filename;
return r; return r;
} }
@ -6869,14 +6860,14 @@ tsubst (t, args, complain, in_decl)
if (TREE_CODE (type) == REFERENCE_TYPE if (TREE_CODE (type) == REFERENCE_TYPE
|| (code == REFERENCE_TYPE && TREE_CODE (type) == VOID_TYPE)) || (code == REFERENCE_TYPE && TREE_CODE (type) == VOID_TYPE))
{ {
static int last_line = 0; static location_t last_loc;
static const char* last_file = 0;
/* We keep track of the last time we issued this error /* We keep track of the last time we issued this error
message to avoid spewing a ton of messages during a message to avoid spewing a ton of messages during a
single bad template instantiation. */ single bad template instantiation. */
if (complain & tf_error if (complain & tf_error
&& (last_line != input_line || last_file != input_filename)) && (last_loc.line != input_line
|| last_loc.file != input_filename))
{ {
if (TREE_CODE (type) == VOID_TYPE) if (TREE_CODE (type) == VOID_TYPE)
error ("forming reference to void"); error ("forming reference to void");
@ -6884,8 +6875,7 @@ tsubst (t, args, complain, in_decl)
error ("forming %s to reference type `%T'", error ("forming %s to reference type `%T'",
(code == POINTER_TYPE) ? "pointer" : "reference", (code == POINTER_TYPE) ? "pointer" : "reference",
type); type);
last_line = input_line; last_loc = input_location;
last_file = input_filename;
} }
return error_mark_node; return error_mark_node;
@ -10759,10 +10749,9 @@ instantiate_decl (d, defer_ok)
tree spec; tree spec;
tree gen_tmpl; tree gen_tmpl;
int pattern_defined; int pattern_defined;
int line = input_line;
int need_push; int need_push;
const char *file = input_filename; location_t saved_loc = input_location;
/* This function should only be used to instantiate templates for /* This function should only be used to instantiate templates for
functions and static member variables. */ functions and static member variables. */
my_friendly_assert (TREE_CODE (d) == FUNCTION_DECL my_friendly_assert (TREE_CODE (d) == FUNCTION_DECL
@ -10825,8 +10814,7 @@ instantiate_decl (d, defer_ok)
else else
pattern_defined = ! DECL_IN_AGGR_P (code_pattern); pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
input_line = DECL_SOURCE_LINE (d); input_location = DECL_SOURCE_LOCATION (d);
input_filename = DECL_SOURCE_FILE (d);
if (pattern_defined) if (pattern_defined)
{ {
@ -10913,8 +10901,7 @@ instantiate_decl (d, defer_ok)
because it's used by add_pending_template. */ because it's used by add_pending_template. */
else if (! pattern_defined || defer_ok) else if (! pattern_defined || defer_ok)
{ {
input_line = line; input_location = saved_loc;
input_filename = file;
if (at_eof && !pattern_defined if (at_eof && !pattern_defined
&& DECL_EXPLICIT_INSTANTIATION (d)) && DECL_EXPLICIT_INSTANTIATION (d))
@ -10941,9 +10928,9 @@ instantiate_decl (d, defer_ok)
regenerate_decl_from_template (d, td); regenerate_decl_from_template (d, td);
/* We already set the file and line above. Reset them now in case /* We already set the file and line above. Reset them now in case
they changed as a result of calling regenerate_decl_from_template. */ they changed as a result of calling
input_line = DECL_SOURCE_LINE (d); regenerate_decl_from_template. */
input_filename = DECL_SOURCE_FILE (d); input_location = DECL_SOURCE_LOCATION (d);
if (TREE_CODE (d) == VAR_DECL) if (TREE_CODE (d) == VAR_DECL)
{ {
@ -11048,9 +11035,7 @@ instantiate_decl (d, defer_ok)
pop_from_top_level (); pop_from_top_level ();
out: out:
input_line = line; input_location = saved_loc;
input_filename = file;
pop_tinst_level (); pop_tinst_level ();
timevar_pop (TV_PARSE); timevar_pop (TV_PARSE);

View File

@ -1804,8 +1804,7 @@ begin_class_definition (t)
} }
/* Update the location of the decl. */ /* Update the location of the decl. */
DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename; DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location;
DECL_SOURCE_LINE (TYPE_NAME (t)) = input_line;
if (TYPE_BEING_DEFINED (t)) if (TYPE_BEING_DEFINED (t))
{ {
@ -2303,8 +2302,7 @@ void
expand_body (fn) expand_body (fn)
tree fn; tree fn;
{ {
int saved_lineno; location_t saved_loc;
const char *saved_input_filename;
tree saved_function; tree saved_function;
/* When the parser calls us after finishing the body of a template /* When the parser calls us after finishing the body of a template
@ -2384,13 +2382,11 @@ expand_body (fn)
return; return;
/* Save the current file name and line number. When we expand the /* Save the current file name and line number. When we expand the
body of the function, we'll set LINENO and INPUT_FILENAME so that body of the function, we'll set INPUT_LOCATION so that
error-mesages come out in the right places. */ error-mesages come out in the right places. */
saved_lineno = input_line; saved_loc = input_location;
saved_input_filename = input_filename;
saved_function = current_function_decl; saved_function = current_function_decl;
input_line = DECL_SOURCE_LINE (fn); input_location = DECL_SOURCE_LOCATION (fn);
input_filename = DECL_SOURCE_FILE (fn);
current_function_decl = fn; current_function_decl = fn;
timevar_push (TV_INTEGRATION); timevar_push (TV_INTEGRATION);
@ -2433,8 +2429,7 @@ expand_body (fn)
/* And restore the current source position. */ /* And restore the current source position. */
current_function_decl = saved_function; current_function_decl = saved_function;
input_line = saved_lineno; input_location = saved_loc;
input_filename = saved_input_filename;
extract_interface_info (); extract_interface_info ();
timevar_pop (TV_EXPAND); timevar_pop (TV_EXPAND);