cp: * pt.c (instantiate_class_template): Set location before substuting bases.
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 15 Aug 2003 10:46:51 +0000 (10:46 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 15 Aug 2003 10:46:51 +0000 (10:46 +0000)
cp: * pt.c (instantiate_class_template): Set location before
substuting bases.
testsuite:
* g++.dg/template/error2.C: New test.
* g++.dg/lookup/using7.C: Adjust errors
* g++.old-deja/g++.pt/crash36.C: Likewise.
* g++.old-deja/g++.pt/derived3.C: Likewise.

From-SVN: r70476

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/using7.C
gcc/testsuite/g++.dg/template/error2.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/crash36.C
gcc/testsuite/g++.old-deja/g++.pt/derived3.C

index 8f188b659b317808c4e99d44103734d607d75f5e..6f8b592cbb0e7837e1020c6c46611c79ab0709da 100644 (file)
@@ -1,5 +1,8 @@
 2003-08-15  Nathan Sidwell  <nathan@codesourcery.com>
 
+       * pt.c (instantiate_class_template): Set location before
+       substuting bases.
+
        * decl.c (make_typename_type): Use my_friendly_assert.
        * pt.c (tsubst_aggr_type): Rearrange context substitution.
 
index 43ecde0441578189853cc7e8b6e600b01c3678ea..722c18e2a34a69b5fbc5fa410c05709e00d27ae7 100644 (file)
@@ -5137,6 +5137,10 @@ instantiate_class_template (tree type)
       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_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
index e491ea1944e20891f4b676e305751f1ae8b27c97..e12c2f7bd3324b77a8307d891350d373ffb0bfb7 100644 (file)
@@ -1,3 +1,10 @@
+2003-08-15  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.dg/template/error2.C: New test.
+       * g++.dg/lookup/using7.C: Adjust errors
+       * g++.old-deja/g++.pt/crash36.C: Likewise.
+       * g++.old-deja/g++.pt/derived3.C: Likewise.
+
 2003-08-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.c-torture/execute/builtins/lib/strcat.c: New.
index 5f187fef56480c01686a0f373973b783a14a8f7e..e62d3f310acf1a066f0cd944984516988e6a3ea3 100644 (file)
@@ -4,7 +4,7 @@ template <typename T, bool=T::X> struct A
 };
 
 template <typename T> struct B : A<T>
-{
+{ // { dg-error "" }
   using A<T>::i; // { dg-error "" } 
 };
 
diff --git a/gcc/testsuite/g++.dg/template/error2.C b/gcc/testsuite/g++.dg/template/error2.C
new file mode 100644 (file)
index 0000000..1ce9b6f
--- /dev/null
@@ -0,0 +1,28 @@
+// { 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" "" }
+}
index 055df04a95f51f0cfe20f25f80cd9ce20f73de18..146c0b137832865451c8d0b10cfd5ef4770ce6bb 100644 (file)
@@ -14,7 +14,7 @@ struct iterator {
 
 template <class Iterator>
 struct reverse_iterator : public
-iterator<typename iterator_traits<Iterator>::iterator_category> {
+iterator<typename iterator_traits<Iterator>::iterator_category> { // { dg-error "" } no type iterator_category
   protected:
   Iterator current;
   
index 24d2c0d720a7acec4a6bafc699ebc5b47c9ae83b..806e0f5c99c7be76f2bf8438b21e9bba7548397c 100644 (file)
@@ -1,14 +1,16 @@
-// { dg-do assemble  }
+// { 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 {};
-       Y y;                    // { dg-error "" } invalid base type
+       class Y : public T
+       { // { dg-error "base type .* fails to be" "" }
+       };
+       Y y;                    // { dg-error "instantiated" "" }
 };
 int main() {
-       X<int> x;               // { dg-error "" } instantiated
+       X<int> x;               // { dg-error "instantiated" "" }
 }