Commit 299f79b5 by Nathan Sidwell Committed by Nathan Sidwell

cpplex.c (_cpp_lex_direct): Set BOL for CPP_EOF tokens.

.:	* cpplex.c (_cpp_lex_direct): Set BOL for CPP_EOF tokens.
	* gcov.c (output_lines): Don't be so fussy about going past EOF.
cp:
	* cp/decl2.c (start_static_storage_duration_function): Take count
	arg, don't check if it wraps round.
	(generate_ctor_or_dtor_function): Add locus arg, use it.
	(generate_ctor_and_dtor_functions_for_priority): Data arg is a
	locus.
	(finish_file): Set line numbers to past EOF for synthesized
	functions.

From-SVN: r65847
parent de0c0e69
2003-04-20 Nathan Sidwell <nathan@codesourcery.com>
* cpplex.c (_cpp_lex_direct): Set BOL for CPP_EOF tokens.
* gcov.c (output_lines): Don't be so fussy about going past EOF.
2003-04-20 Neil Booth <neil@daikokuya.co.uk> 2003-04-20 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in (LIBCPP_OBJS): Add cppcharset.o. * Makefile.in (LIBCPP_OBJS): Add cppcharset.o.
......
2003-04-19 Nathan Sidwell <nathan@codesourcery.com> 2003-04-20 Nathan Sidwell <nathan@codesourcery.com>
* cp/decl2.c (start_static_storage_duration_function): Take count
arg, don't check if it wraps round.
(generate_ctor_or_dtor_function): Add locus arg, use it.
(generate_ctor_and_dtor_functions_for_priority): Data arg is a
locus.
(finish_file): Set line numbers to past EOF for synthesized
functions.
2003-04-20 Nathan Sidwell <nathan@codesourcery.com>
PR c++/10405 PR c++/10405
* search.c (lookup_field_1): Final scan goes backwards for * search.c (lookup_field_1): Final scan goes backwards for
......
...@@ -73,14 +73,14 @@ static tree merge_functions (tree, tree); ...@@ -73,14 +73,14 @@ static tree merge_functions (tree, tree);
static tree decl_namespace (tree); static tree decl_namespace (tree);
static tree validate_nonmember_using_decl (tree, tree *, tree *); static tree validate_nonmember_using_decl (tree, tree *, tree *);
static void do_nonmember_using_decl (tree, tree, tree, tree, tree *, tree *); static void do_nonmember_using_decl (tree, tree, tree, tree, tree *, tree *);
static tree start_static_storage_duration_function (void); static tree start_static_storage_duration_function (unsigned);
static void finish_static_storage_duration_function (tree); static void finish_static_storage_duration_function (tree);
static priority_info get_priority_info (int); static priority_info get_priority_info (int);
static void do_static_initialization (tree, tree); static void do_static_initialization (tree, tree);
static void do_static_destruction (tree); static void do_static_destruction (tree);
static tree start_static_initialization_or_destruction (tree, int); static tree start_static_initialization_or_destruction (tree, int);
static void finish_static_initialization_or_destruction (tree); static void finish_static_initialization_or_destruction (tree);
static void generate_ctor_or_dtor_function (bool, int); static void generate_ctor_or_dtor_function (bool, int, location_t *);
static int generate_ctor_and_dtor_functions_for_priority (splay_tree_node, static int generate_ctor_and_dtor_functions_for_priority (splay_tree_node,
void *); void *);
static tree prune_vars_needing_no_initialization (tree *); static tree prune_vars_needing_no_initialization (tree *);
...@@ -2076,10 +2076,8 @@ static splay_tree priority_info_map; ...@@ -2076,10 +2076,8 @@ static splay_tree priority_info_map;
translation unit. */ translation unit. */
static tree static tree
start_static_storage_duration_function (void) start_static_storage_duration_function (unsigned count)
{ {
static unsigned ssdf_number;
tree parm_types; tree parm_types;
tree type; tree type;
tree body; tree body;
...@@ -2087,14 +2085,7 @@ start_static_storage_duration_function (void) ...@@ -2087,14 +2085,7 @@ start_static_storage_duration_function (void)
/* Create the identifier for this function. It will be of the form /* Create the identifier for this function. It will be of the form
SSDF_IDENTIFIER_<number>. */ SSDF_IDENTIFIER_<number>. */
sprintf (id, "%s_%u", SSDF_IDENTIFIER, ssdf_number++); sprintf (id, "%s_%u", SSDF_IDENTIFIER, count);
if (ssdf_number == 0)
{
/* Overflow occurred. That means there are at least 4 billion
initialization functions. */
sorry ("too many initialization functions required");
abort ();
}
/* Create the parameters. */ /* Create the parameters. */
parm_types = void_list_node; parm_types = void_list_node;
...@@ -2475,13 +2466,17 @@ write_out_vars (tree vars) ...@@ -2475,13 +2466,17 @@ write_out_vars (tree vars)
storage duration having the indicated PRIORITY. */ storage duration having the indicated PRIORITY. */
static void static void
generate_ctor_or_dtor_function (bool constructor_p, int priority) generate_ctor_or_dtor_function (bool constructor_p, int priority,
location_t *locus)
{ {
char function_key; char function_key;
tree arguments; tree arguments;
tree body; tree body;
size_t i; size_t i;
input_filename = locus->file;
lineno = locus->line++;
/* We use `I' to indicate initialization and `D' to indicate /* We use `I' to indicate initialization and `D' to indicate
destruction. */ destruction. */
if (constructor_p) if (constructor_p)
...@@ -2526,9 +2521,9 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority) ...@@ -2526,9 +2521,9 @@ generate_ctor_or_dtor_function (bool constructor_p, int priority)
indicated by N. */ indicated by N. */
static int static int
generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, void * data)
void * data ATTRIBUTE_UNUSED)
{ {
location_t *locus = data;
int priority = (int) n->key; int priority = (int) n->key;
priority_info pi = (priority_info) n->value; priority_info pi = (priority_info) n->value;
...@@ -2536,10 +2531,10 @@ generate_ctor_and_dtor_functions_for_priority (splay_tree_node n, ...@@ -2536,10 +2531,10 @@ generate_ctor_and_dtor_functions_for_priority (splay_tree_node n,
needed. */ needed. */
if (pi->initializations_p if (pi->initializations_p
|| (priority == DEFAULT_INIT_PRIORITY && static_ctors)) || (priority == DEFAULT_INIT_PRIORITY && static_ctors))
generate_ctor_or_dtor_function (/*constructor_p=*/true, priority); generate_ctor_or_dtor_function (/*constructor_p=*/true, priority, locus);
if (pi->destructions_p if (pi->destructions_p
|| (priority == DEFAULT_INIT_PRIORITY && static_dtors)) || (priority == DEFAULT_INIT_PRIORITY && static_dtors))
generate_ctor_or_dtor_function (/*constructor_p=*/false, priority); generate_ctor_or_dtor_function (/*constructor_p=*/false, priority, locus);
/* Keep iterating. */ /* Keep iterating. */
return 0; return 0;
...@@ -2556,7 +2551,11 @@ finish_file () ...@@ -2556,7 +2551,11 @@ finish_file ()
tree vars; tree vars;
bool reconsider; bool reconsider;
size_t i; size_t i;
location_t locus;
unsigned ssdf_count = 0;
locus.file = input_filename;
locus.line = lineno;
at_eof = 1; at_eof = 1;
/* Bad parse errors. Just forget about it. */ /* Bad parse errors. Just forget about it. */
...@@ -2683,7 +2682,13 @@ finish_file () ...@@ -2683,7 +2682,13 @@ finish_file ()
out. That's a deficiency in the back-end. When this is out. That's a deficiency in the back-end. When this is
fixed, these initialization functions could all become fixed, these initialization functions could all become
inline, with resulting performance improvements. */ inline, with resulting performance improvements. */
tree ssdf_body = start_static_storage_duration_function (); tree ssdf_body;
/* Set the line and file, so that it is obviously not from
the source file. */
input_filename = locus.file;
lineno = locus.line;
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. */
write_out_vars (vars); write_out_vars (vars);
...@@ -2710,12 +2715,16 @@ finish_file () ...@@ -2710,12 +2715,16 @@ 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;
lineno = 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
us to need more inline functions, more template us to need more inline functions, more template
instantiations, etc. */ instantiations, etc. */
reconsider = true; reconsider = true;
ssdf_count++;
locus.line++;
} }
for (i = 0; i < deferred_fns_used; ++i) for (i = 0; i < deferred_fns_used; ++i)
...@@ -2838,15 +2847,16 @@ finish_file () ...@@ -2838,15 +2847,16 @@ finish_file ()
if (priority_info_map) if (priority_info_map)
splay_tree_foreach (priority_info_map, splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority, generate_ctor_and_dtor_functions_for_priority,
/*data=*/0); /*data=*/&locus);
else else
{ {
if (static_ctors) if (static_ctors)
generate_ctor_or_dtor_function (/*constructor_p=*/true, generate_ctor_or_dtor_function (/*constructor_p=*/true,
DEFAULT_INIT_PRIORITY); DEFAULT_INIT_PRIORITY, &locus);
if (static_dtors) if (static_dtors)
generate_ctor_or_dtor_function (/*constructor_p=*/false, generate_ctor_or_dtor_function (/*constructor_p=*/false,
DEFAULT_INIT_PRIORITY); DEFAULT_INIT_PRIORITY, &locus);
} }
/* We're done with the splay-tree now. */ /* We're done with the splay-tree now. */
...@@ -2886,6 +2896,8 @@ finish_file () ...@@ -2886,6 +2896,8 @@ finish_file ()
dump_tree_statistics (); dump_tree_statistics ();
dump_time_statistics (); dump_time_statistics ();
} }
input_filename = locus.file;
lineno = 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
......
...@@ -767,6 +767,12 @@ _cpp_lex_direct (pfile) ...@@ -767,6 +767,12 @@ _cpp_lex_direct (pfile)
if (!_cpp_get_fresh_line (pfile)) if (!_cpp_get_fresh_line (pfile))
{ {
result->type = CPP_EOF; result->type = CPP_EOF;
if (!pfile->state.in_directive)
{
/* Tell the compiler the line number of the EOF token. */
result->line = pfile->line;
result->flags = BOL;
}
return result; return result;
} }
if (!pfile->keep_tokens) if (!pfile->keep_tokens)
......
...@@ -1862,16 +1862,13 @@ output_lines (gcov_file, src) ...@@ -1862,16 +1862,13 @@ output_lines (gcov_file, src)
{ {
retval = fgets (string, STRING_SIZE, source_file); retval = fgets (string, STRING_SIZE, source_file);
if (!retval) if (!retval)
{ break;
fnotice (stderr, "%s:unexpected EOF\n", src->name);
break;
}
fputs (retval, gcov_file); fputs (retval, gcov_file);
} }
while (!retval[0] || retval[strlen (retval) - 1] != '\n'); while (!retval[0] || retval[strlen (retval) - 1] != '\n');
} }
if (!retval) if (!retval)
fputs ("??\n", gcov_file); fputs ("/*EOF*/\n", gcov_file);
if (flag_all_blocks) if (flag_all_blocks)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment