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>
* class.c (finish_struct): Rename lineno to input_line.

View File

@ -5251,8 +5251,7 @@ unreverse_member_declarations (tree t)
tree
finish_struct (tree t, tree attributes)
{
const char *saved_filename = input_filename;
int saved_lineno = input_line;
location_t saved_loc = input_location;
/* Now that we've got all the field declarations, reverse everything
as necessary. */
@ -5262,8 +5261,7 @@ finish_struct (tree t, tree attributes)
/* Nadger the current location so that diagnostics point to the start of
the struct, not the end. */
input_filename = DECL_SOURCE_FILE (TYPE_NAME (t));
input_line = DECL_SOURCE_LINE (TYPE_NAME (t));
input_location = DECL_SOURCE_LOCATION (TYPE_NAME (t));
if (processing_template_decl)
{
@ -5273,8 +5271,7 @@ finish_struct (tree t, tree attributes)
else
finish_struct_1 (t);
input_filename = saved_filename;
input_line = saved_lineno;
input_location = saved_loc;
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
error if it is not defined. */
DECL_SOURCE_LINE (decl) = input_line;
DECL_SOURCE_FILE (decl) = input_filename;
DECL_SOURCE_LOCATION (decl) = input_location;
/* Record the fact that this identifier is bound to this label. */
SET_IDENTIFIER_LABEL_VALUE (id, decl);
@ -4625,8 +4624,7 @@ use_label (tree decl)
new_ent->label_decl = decl;
new_ent->names_in_scope = current_binding_level->names;
new_ent->binding_level = current_binding_level;
new_ent->o_goto_locus.line = input_line;
new_ent->o_goto_locus.file = input_filename;
new_ent->o_goto_locus = input_location;
new_ent->next = named_label_uses;
named_label_uses = new_ent;
}

View File

@ -178,8 +178,7 @@ warn_if_unknown_interface (tree decl)
if (flag_alt_external_templates)
{
tree til = tinst_for_decl ();
int sl = input_line;
const char *sf = input_filename;
location_t saved_loc = input_location;
if (til)
{
@ -188,8 +187,7 @@ warn_if_unknown_interface (tree decl)
}
warning ("template `%#D' instantiated in file without #pragma interface",
decl);
input_line = sl;
input_filename = sf;
input_location = saved_loc;
}
else
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
that the debugger will show somewhat sensible file and line
information. */
input_filename = DECL_SOURCE_FILE (decl);
input_line = DECL_SOURCE_LINE (decl);
input_location = DECL_SOURCE_LOCATION (decl);
/* Because of:
@ -2474,8 +2471,8 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority,
tree body;
size_t i;
input_filename = locus->file;
input_line = locus->line++;
input_location = *locus;
locus->line++;
/* We use `I' to indicate initialization and `D' to indicate
destruction. */
@ -2554,8 +2551,7 @@ finish_file ()
location_t locus;
unsigned ssdf_count = 0;
locus.file = input_filename;
locus.line = input_line;
locus = input_location;
at_eof = 1;
/* 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
the source file. */
input_filename = locus.file;
input_line = locus.line;
input_location = locus;
ssdf_body = start_static_storage_duration_function (ssdf_count);
/* 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
round. */
input_filename = locus.file;
input_line = locus.line;
input_location = locus;
finish_static_storage_duration_function (ssdf_body);
/* All those initializations and finalizations might cause
@ -2905,8 +2899,7 @@ finish_file ()
dump_tree_statistics ();
dump_time_statistics ();
}
input_filename = locus.file;
input_line = locus.line;
input_location = locus;
}
/* 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)
{
tree p = current_instantiation ();
int line = input_line;
const char *file = input_filename;
location_t location = input_location;
if (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. */;
else
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),
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
line = TINST_LINE (p);
file = TINST_FILE (p);
location.line = TINST_LINE (p);
location.file = TINST_FILE (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. */

View File

@ -2675,8 +2675,7 @@ create_temporary_var (type)
decl = build_decl (VAR_DECL, NULL_TREE, type);
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_SOURCE_FILE (decl) = input_filename;
DECL_SOURCE_LINE (decl) = input_line;
DECL_SOURCE_LOCATION (decl) = input_location;
DECL_IGNORED_P (decl) = 1;
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
user a hint as to why we are attempting to generate the
function. */
DECL_SOURCE_LINE (fndecl) = input_line;
DECL_SOURCE_FILE (fndecl) = input_filename;
DECL_SOURCE_LOCATION (fndecl) = input_location;
interface_unknown = 1;
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.
Otherwise, this value is RID_MAX. */
enum rid keyword;
/* The file in which this token was found. */
const char *file_name;
/* The line at which this token was found. */
int line_number;
/* The location at which this token was found. */
location_t location;
} cp_token;
/* 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. */
if (token->type != CPP_EOF)
{
input_line = token->line_number;
input_filename = token->file_name;
}
input_location = token->location;
}
/* 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)
{
token->type = CPP_EOF;
token->line_number = 0;
token->file_name = NULL;
token->location.line = 0;
token->location.file = NULL;
token->value = NULL_TREE;
token->keyword = RID_MAX;
@ -651,8 +646,7 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer ATTRIBUTE_UNUSED ,
}
}
/* Now we've got our token. */
token->line_number = input_line;
token->file_name = input_filename;
token->location = input_location;
/* Check to see if this token is a keyword. */
if (token->type == CPP_NAME
@ -5591,7 +5585,7 @@ cp_parser_statement (cp_parser* parser)
/* Peek at the next token. */
token = cp_lexer_peek_token (parser->lexer);
/* 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
statement we have. */
if (token->type == CPP_KEYWORD)

View File

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

View File

@ -1804,8 +1804,7 @@ begin_class_definition (t)
}
/* Update the location of the decl. */
DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
DECL_SOURCE_LINE (TYPE_NAME (t)) = input_line;
DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location;
if (TYPE_BEING_DEFINED (t))
{
@ -2303,8 +2302,7 @@ void
expand_body (fn)
tree fn;
{
int saved_lineno;
const char *saved_input_filename;
location_t saved_loc;
tree saved_function;
/* When the parser calls us after finishing the body of a template
@ -2384,13 +2382,11 @@ expand_body (fn)
return;
/* 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. */
saved_lineno = input_line;
saved_input_filename = input_filename;
saved_loc = input_location;
saved_function = current_function_decl;
input_line = DECL_SOURCE_LINE (fn);
input_filename = DECL_SOURCE_FILE (fn);
input_location = DECL_SOURCE_LOCATION (fn);
current_function_decl = fn;
timevar_push (TV_INTEGRATION);
@ -2433,8 +2429,7 @@ expand_body (fn)
/* And restore the current source position. */
current_function_decl = saved_function;
input_line = saved_lineno;
input_filename = saved_input_filename;
input_location = saved_loc;
extract_interface_info ();
timevar_pop (TV_EXPAND);