Commit 6573e8a0 by Jason Merrill Committed by Jason Merrill

pt.c (tinst_level_tick, [...]): Replace with last_error_tinst_level.

gcc/cp/
	* pt.c (tinst_level_tick, last_template_error_tick): Replace with
	last_error_tinst_level.
	(push_tinst_level, pop_tinst_level): Adjust.
	(problematic_instantiation_changed): Adjust.
	(record_last_problematic_instantiation): Adjust.
	* error.c (cp_print_error_function): Don't print
	current_function_decl if we're in a template instantiation context.
	(print_instantiation_full_context): Always print first line.
gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Prune "In substitution" too.

From-SVN: r176366
parent 3d2f6864
2011-07-16 Jason Merrill <jason@redhat.com>
* pt.c (tinst_level_tick, last_template_error_tick): Replace with
last_error_tinst_level.
(push_tinst_level, pop_tinst_level): Adjust.
(problematic_instantiation_changed): Adjust.
(record_last_problematic_instantiation): Adjust.
* error.c (cp_print_error_function): Don't print
current_function_decl if we're in a template instantiation context.
(print_instantiation_full_context): Always print first line.
2011-07-16 Nathan Froyd <froydnj@codesourcery.com> 2011-07-16 Nathan Froyd <froydnj@codesourcery.com>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
......
...@@ -2784,6 +2784,10 @@ static void ...@@ -2784,6 +2784,10 @@ static void
cp_print_error_function (diagnostic_context *context, cp_print_error_function (diagnostic_context *context,
diagnostic_info *diagnostic) diagnostic_info *diagnostic)
{ {
/* If we are in an instantiation context, current_function_decl is likely
to be wrong, so just rely on print_instantiation_full_context. */
if (current_instantiation ())
return;
if (diagnostic_last_function_changed (context, diagnostic)) if (diagnostic_last_function_changed (context, diagnostic))
{ {
const char *old_prefix = context->printer->prefix; const char *old_prefix = context->printer->prefix;
...@@ -2927,26 +2931,15 @@ print_instantiation_full_context (diagnostic_context *context) ...@@ -2927,26 +2931,15 @@ print_instantiation_full_context (diagnostic_context *context)
if (p) if (p)
{ {
if (current_function_decl != p->decl pp_verbatim (context->printer,
&& current_function_decl != NULL_TREE) TREE_CODE (p->decl) == TREE_LIST
/* We can get here during the processing of some synthesized ? _("%s: In substitution of %qS:\n")
method. Then, P->DECL will be the function that's causing : _("%s: In instantiation of %q#D:\n"),
the synthesis. */ LOCATION_FILE (location),
; p->decl);
else
{ location = p->locus;
if (current_function_decl == p->decl) p = p->next;
/* Avoid redundancy with the "In function" line. */;
else
pp_verbatim (context->printer,
_("%s: In instantiation of %qs:\n"),
LOCATION_FILE (location),
decl_as_string_translate (p->decl,
TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
location = p->locus;
p = p->next;
}
} }
print_instantiation_partial_context (context, p, location); print_instantiation_partial_context (context, p, location);
......
...@@ -7766,8 +7766,7 @@ extern int max_tinst_depth; ...@@ -7766,8 +7766,7 @@ extern int max_tinst_depth;
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
int depth_reached; int depth_reached;
#endif #endif
static int tinst_level_tick; static GTY(()) struct tinst_level *last_error_tinst_level;
static int last_template_error_tick;
/* We're starting to instantiate D; record the template instantiation context /* We're starting to instantiate D; record the template instantiation context
for diagnostics and to restore it later. */ for diagnostics and to restore it later. */
...@@ -7779,7 +7778,7 @@ push_tinst_level (tree d) ...@@ -7779,7 +7778,7 @@ push_tinst_level (tree d)
if (tinst_depth >= max_tinst_depth) if (tinst_depth >= max_tinst_depth)
{ {
last_template_error_tick = tinst_level_tick; last_error_tinst_level = current_tinst_level;
if (TREE_CODE (d) == TREE_LIST) if (TREE_CODE (d) == TREE_LIST)
error ("template instantiation depth exceeds maximum of %d (use " error ("template instantiation depth exceeds maximum of %d (use "
"-ftemplate-depth= to increase the maximum) substituting %qS", "-ftemplate-depth= to increase the maximum) substituting %qS",
...@@ -7814,7 +7813,6 @@ push_tinst_level (tree d) ...@@ -7814,7 +7813,6 @@ push_tinst_level (tree d)
depth_reached = tinst_depth; depth_reached = tinst_depth;
#endif #endif
++tinst_level_tick;
return 1; return 1;
} }
...@@ -7829,7 +7827,6 @@ pop_tinst_level (void) ...@@ -7829,7 +7827,6 @@ pop_tinst_level (void)
input_location = current_tinst_level->locus; input_location = current_tinst_level->locus;
current_tinst_level = current_tinst_level->next; current_tinst_level = current_tinst_level->next;
--tinst_depth; --tinst_depth;
++tinst_level_tick;
} }
/* We're instantiating a deferred template; restore the template /* We're instantiating a deferred template; restore the template
...@@ -13961,6 +13958,7 @@ deduction_tsubst_fntype (tree fn, tree targs, tsubst_flags_t complain) ...@@ -13961,6 +13958,7 @@ deduction_tsubst_fntype (tree fn, tree targs, tsubst_flags_t complain)
static bool excessive_deduction_depth; static bool excessive_deduction_depth;
static int deduction_depth; static int deduction_depth;
struct pending_template *old_last_pend = last_pending_template; struct pending_template *old_last_pend = last_pending_template;
struct tinst_level *old_error_tinst = last_error_tinst_level;
tree fntype = TREE_TYPE (fn); tree fntype = TREE_TYPE (fn);
tree tinst; tree tinst;
...@@ -13993,8 +13991,10 @@ deduction_tsubst_fntype (tree fn, tree targs, tsubst_flags_t complain) ...@@ -13993,8 +13991,10 @@ deduction_tsubst_fntype (tree fn, tree targs, tsubst_flags_t complain)
} }
pop_tinst_level (); pop_tinst_level ();
/* We can't free this if a pending_template entry is pointing at it. */ /* We can't free this if a pending_template entry or last_error_tinst_level
if (last_pending_template == old_last_pend) is pointing at it. */
if (last_pending_template == old_last_pend
&& last_error_tinst_level == old_error_tinst)
ggc_free (tinst); ggc_free (tinst);
return r; return r;
} }
...@@ -18564,14 +18564,14 @@ get_mostly_instantiated_function_type (tree decl) ...@@ -18564,14 +18564,14 @@ get_mostly_instantiated_function_type (tree decl)
int int
problematic_instantiation_changed (void) problematic_instantiation_changed (void)
{ {
return last_template_error_tick != tinst_level_tick; return current_tinst_level != last_error_tinst_level;
} }
/* Remember current template involved in diagnostics. */ /* Remember current template involved in diagnostics. */
void void
record_last_problematic_instantiation (void) record_last_problematic_instantiation (void)
{ {
last_template_error_tick = tinst_level_tick; last_error_tinst_level = current_tinst_level;
} }
struct tinst_level * struct tinst_level *
......
2011-07-16 Jason Merrill <jason@redhat.com>
* lib/prune.exp (prune_gcc_output): Prune "In substitution" too.
2011-07-16 Nathan Froyd <froydnj@codesourcery.com> 2011-07-16 Nathan Froyd <froydnj@codesourcery.com>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
proc prune_gcc_output { text } { proc prune_gcc_output { text } {
#send_user "Before:$text\n" #send_user "Before:$text\n"
regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|program|subroutine|block-data)\[^\n\]*" $text "" text regsub -all "(^|\n)(\[^\n\]*: )?In ((static member |lambda )?function|member|method|(copy )?constructor|destructor|instantiation|substitution|program|subroutine|block-data)\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*(: )?At (top level|global scope):\[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: (recursively )?required \[^\n\]*" $text "" text
regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text regsub -all "(^|\n)\[^\n\]*: . skipping \[0-9\]* instantiation contexts \[^\n\]*" $text "" text
......
...@@ -47,6 +47,6 @@ main() ...@@ -47,6 +47,6 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-error "In member function" "" { target *-*-* } 0 } // { dg-error "In instantiation" "" { target *-*-* } 0 }
// { dg-error "cannot convert" "" { target *-*-* } 0 } // { dg-error "cannot convert" "" { target *-*-* } 0 }
// { dg-error "required from" "" { target *-*-* } 0 } // { dg-error "required from" "" { target *-*-* } 0 }
...@@ -46,6 +46,6 @@ main() ...@@ -46,6 +46,6 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-error "In member function" "" { target *-*-* } 0 } // { dg-error "In instantiation" "" { target *-*-* } 0 }
// { dg-error "cannot convert" "" { target *-*-* } 0 } // { dg-error "cannot convert" "" { target *-*-* } 0 }
// { dg-error "required from" "" { target *-*-* } 0 } // { dg-error "required from" "" { target *-*-* } 0 }
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