summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-18 17:35:47 +0000
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-18 17:35:47 +0000
commit44e4cd4483f9dbe2fcff96de63afcddf3daa7362 (patch)
treee0d0d5427e19b9b6f74ebbf6a9d080c7173eebcb
parent62ba96505198722060a9ecc8925d9c22328d1f98 (diff)
downloadppe42-gcc-44e4cd4483f9dbe2fcff96de63afcddf3daa7362.tar.gz
ppe42-gcc-44e4cd4483f9dbe2fcff96de63afcddf3daa7362.zip
PR c++/12495
* pt.c (lookup_template_class): Handle when current_class_type is a local class. * g++.dg/template/crash21.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72643 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/crash12.C16
4 files changed, 33 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b5cba3c7aaf..344083acb49 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-10-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/12495
+ * pt.c (lookup_template_class): Handle when current_class_type
+ is a local class.
+
2003-10-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/2513
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ffc347c7a01..32b146f5294 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4163,14 +4163,12 @@ lookup_template_class (tree d1,
tree ctx;
for (ctx = current_class_type;
- ctx;
- ctx = TYPE_CONTEXT (ctx))
- {
- if (TREE_CODE (ctx) == NAMESPACE_DECL)
- break;
- if (same_type_p (ctx, template_type))
- goto found_ctx;
- }
+ ctx && TREE_CODE (ctx) != NAMESPACE_DECL;
+ ctx = (TYPE_P (ctx)
+ ? TYPE_CONTEXT (ctx)
+ : DECL_CONTEXT (ctx)))
+ if (TYPE_P (ctx) && same_type_p (ctx, template_type))
+ goto found_ctx;
/* We're not in the scope of the class, so the
TEMPLATE_TYPE is not the type we want after all. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5cfe1e48523..41e3d856912 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/12495
+ * g++.dg/template/crash21.C: New test.
+
2003-10-17 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/2513
diff --git a/gcc/testsuite/g++.dg/template/crash12.C b/gcc/testsuite/g++.dg/template/crash12.C
new file mode 100644
index 00000000000..e2231e06b91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/crash12.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+
+// Origin: rmerkert@alphatech.com
+// Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/12495: ICE looking up class template in local class.
+
+template <typename> struct A {};
+
+template <typename T> void foo()
+{
+ struct B
+ {
+ B (const A<T>&);
+ };
+}
OpenPOWER on IntegriCloud