This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH,committed] Fix PR11616 (wrong line number afterinstantiate_pending_template)


Hi

The 'instantiate_pending_template' calls 'reopen_tinst_level'
which destroys current line number information.  So all
error messages afterward (like when emitting vtable) no longer 
have the right line number.  The patch below fixes this problem
by saving current line number and restore upon exit
'instantiate_pending_template'.  Tested on i686-pc-linux-gnu.
Committed to trunk as obvious.

--Kriang

2003-11-05  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/11616
	* pt.c (instantiate_pending_templates): Save and restore
	input_location.

2003-11-05  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/11616
	* g++.dg/template/instantiate5.C: New test.

diff -cprN gcc-main-save/gcc/cp/pt.c gcc-main-new/gcc/cp/pt.c
*** gcc-main-save/gcc/cp/pt.c	Fri Oct 24 21:39:22 2003
--- gcc-main-new/gcc/cp/pt.c	Tue Nov  4 19:19:17 2003
*************** instantiate_pending_templates (void)
*** 11037,11042 ****
--- 11037,11043 ----
    tree last = NULL_TREE;
    int instantiated_something = 0;
    int reconsider;
+   location_t saved_loc = input_location;
    
    do 
      {
*************** instantiate_pending_templates (void)
*** 11111,11116 ****
--- 11112,11118 ----
      } 
    while (reconsider);
  
+   input_location = saved_loc;
    return instantiated_something;
  }
  
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/template/instantiate5.C gcc-main-new/gcc/testsuite/g++.dg/template/instantiate5.C
*** gcc-main-save/gcc/testsuite/g++.dg/template/instantiate5.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/template/instantiate5.C	Wed Nov  5 21:28:51 2003
***************
*** 0 ****
--- 1,24 ----
+ // { dg-do compile }
+ 
+ // Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+ 
+ // PR c++/11616: Incorrect line number in diagnostics
+ 
+ template <int> struct A
+ {
+   static const int i=0;
+ };
+ 
+ int baz() { return A<0>::i; }
+ 
+ struct B
+ {
+   static void foo (int);	// { dg-error "candidates" }
+ };
+ 
+ template <typename T> struct C
+ {
+   virtual void bar() const { T::foo(); } // { dg-error "no matching function" }
+ };
+ 
+ C<B> c;				// { dg-error "instantiated" }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]