From: Nathan Sidwell Date: Fri, 15 Aug 2003 10:46:51 +0000 (+0000) Subject: cp: * pt.c (instantiate_class_template): Set location before substuting bases. X-Git-Tag: releases/gcc-3.4.0~4242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68ea098a059c352835b2090a02a163f47560ef17;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8f188b659b31..6f8b592cbb0e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2003-08-15 Nathan Sidwell + * 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 43ecde044157..722c18e2a34a 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 e491ea1944e2..e12c2f7bd332 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2003-08-15 Nathan Sidwell + + * 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 * 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 5f187fef5648..e62d3f310acf 100644 --- a/gcc/testsuite/g++.dg/lookup/using7.C +++ b/gcc/testsuite/g++.dg/lookup/using7.C @@ -4,7 +4,7 @@ template struct A }; template struct B : A -{ +{ // { dg-error "" } using A::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 000000000000..1ce9b6f5174e --- /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 + +// instantiated from did not indicate the nested class + +template struct X +{ + T m; // { dg-error "" "" } +}; + +template +struct Derived +{ + class Nested : public X + { // { dg-error "instantiated" + }; + + Nested m; // { dg-error "instantiated" "" } + + void Foo (); +}; + +void Foo (Derived &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 055df04a95f5..146c0b137832 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 struct reverse_iterator : public -iterator::iterator_category> { +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 24d2c0d720a7..806e0f5c99c7 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 , Level Set Systems, Inc. // Copyright (C) 1999, 2002 Free Software Foundation template 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 x; // { dg-error "" } instantiated + X x; // { dg-error "instantiated" "" } }