This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: error location fix
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Mark Mitchell <mitchell at codesourcery dot com>
- Date: Fri, 15 Aug 2003 11:54:38 +0100
- Subject: [C++ PATCH]: error location fix
- Organization: Codesourcery LLC
I've installed this fix to better indicate an error location. It took
me ages to determine the problem with some code, as the indicated line
was no where near the instantiation problem.
booted & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.754
diff -c -3 -p -r1.754 pt.c
*** cp/pt.c 10 Aug 2003 15:10:34 -0000 1.754
--- cp/pt.c 15 Aug 2003 10:04:12 -0000
*************** instantiate_class_template (tree type)
*** 5139,5144 ****
--- 5139,5148 ----
SET_CLASSTYPE_INTERFACE_UNKNOWN (type);
}
+ /* Set the input location to the template definition. This is needed
+ if tsubsting causes an error. */
+ input_location = DECL_SOURCE_LOCATION (TYPE_NAME (pattern));
+
TYPE_HAS_CONSTRUCTOR (type) = TYPE_HAS_CONSTRUCTOR (pattern);
TYPE_HAS_DESTRUCTOR (type) = TYPE_HAS_DESTRUCTOR (pattern);
TYPE_OVERLOADS_CALL_EXPR (type) = TYPE_OVERLOADS_CALL_EXPR (pattern);
Index: testsuite/g++.dg/lookup/using7.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/lookup/using7.C,v
retrieving revision 1.1
diff -c -3 -p -r1.1 using7.C
*** testsuite/g++.dg/lookup/using7.C 17 Jun 2003 22:24:58 -0000 1.1
--- testsuite/g++.dg/lookup/using7.C 15 Aug 2003 10:04:26 -0000
*************** template <typename T, bool=T::X> struct
*** 4,10 ****
};
template <typename T> struct B : A<T>
! {
using A<T>::i; // { dg-error "" }
};
--- 4,10 ----
};
template <typename T> struct B : A<T>
! { // { dg-error "" }
using A<T>::i; // { dg-error "" }
};
Index: testsuite/g++.old-deja/g++.pt/crash36.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.pt/crash36.C,v
retrieving revision 1.6
diff -c -3 -p -r1.6 crash36.C
*** testsuite/g++.old-deja/g++.pt/crash36.C 1 May 2003 02:02:53 -0000 1.6
--- testsuite/g++.old-deja/g++.pt/crash36.C 15 Aug 2003 10:04:35 -0000
*************** struct iterator {
*** 14,20 ****
template <class Iterator>
struct reverse_iterator : public
! iterator<typename iterator_traits<Iterator>::iterator_category> {
protected:
Iterator current;
--- 14,20 ----
template <class Iterator>
struct reverse_iterator : public
! iterator<typename iterator_traits<Iterator>::iterator_category> { // { dg-error "" } no type iterator_category
protected:
Iterator current;
Index: testsuite/g++.old-deja/g++.pt/derived3.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.pt/derived3.C,v
retrieving revision 1.5
diff -c -3 -p -r1.5 derived3.C
*** testsuite/g++.old-deja/g++.pt/derived3.C 1 May 2003 02:02:53 -0000 1.5
--- testsuite/g++.old-deja/g++.pt/derived3.C 15 Aug 2003 10:04:35 -0000
***************
*** 1,14 ****
! // { dg-do assemble }
// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
// Copyright (C) 1999, 2002 Free Software Foundation
template<class T>
class X {
! class Y : public T {};
! Y y; // { dg-error "" } invalid base type
};
int main() {
! X<int> x; // { dg-error "" } instantiated
}
--- 1,16 ----
! // { dg-do compile }
// by Paul Burchard <burchard@pobox.com>, Level Set Systems, Inc.
// Copyright (C) 1999, 2002 Free Software Foundation
template<class T>
class X {
! class Y : public T
! { // { dg-error "base type .* fails to be" "" }
! };
! Y y; // { dg-error "instantiated" "" }
};
int main() {
! X<int> x; // { dg-error "instantiated" "" }
}
// { dg-do compile }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Aug 2003 <nathan@codesourcery.com>
// instantiated from did not indicate the nested class
template<class T> struct X
{
T m; // { dg-error "" "" }
};
template<class T >
struct Derived
{
class Nested : public X<T>
{ // { dg-error "instantiated"
};
Nested m; // { dg-error "instantiated" "" }
void Foo ();
};
void Foo (Derived<void> &x)
{
x.Foo (); // { dg-error "instantiated" "" }
}