diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-08-15 10:46:51 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-08-15 10:46:51 +0000 |
commit | 68ea098a059c352835b2090a02a163f47560ef17 (patch) | |
tree | 381dcd409dcfdf722aba79a14047cc2baa00a58a | |
parent | 4f7847cab9999f228bd0ebf17dda3a1cdde94d02 (diff) | |
download | gcc-68ea098a059c352835b2090a02a163f47560ef17.zip gcc-68ea098a059c352835b2090a02a163f47560ef17.tar.gz gcc-68ea098a059c352835b2090a02a163f47560ef17.tar.bz2 |
cp: * pt.c (instantiate_class_template): Set location before substuting bases.
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
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/using7.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/error2.C | 28 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/crash36.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/derived3.C | 10 |
7 files changed, 50 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8f188b6..6f8b592 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 43ecde0..722c18e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e491ea1..e12c2f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/g++.dg/lookup/using7.C b/gcc/testsuite/g++.dg/lookup/using7.C index 5f187fe..e62d3f3 100644 --- a/gcc/testsuite/g++.dg/lookup/using7.C +++ b/gcc/testsuite/g++.dg/lookup/using7.C @@ -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 index 0000000..1ce9b6f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error2.C @@ -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" "" } +} diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C index 055df04..146c0b1 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash36.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash36.C @@ -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; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/derived3.C b/gcc/testsuite/g++.old-deja/g++.pt/derived3.C index 24d2c0d..806e0f5 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/derived3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/derived3.C @@ -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" "" } } |