re PR c++/12495 (ICE in cp/typeck.c:907)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sat, 18 Oct 2003 17:35:47 +0000 (17:35 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sat, 18 Oct 2003 17:35:47 +0000 (17:35 +0000)
PR c++/12495
* pt.c (lookup_template_class): Handle when current_class_type
is a local class.

* g++.dg/template/crash21.C: New test.

From-SVN: r72643

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash12.C [new file with mode: 0644]

index b5cba3c7aaf1ef5d1be3a9729431bdb616a43dc0..344083acb49c42c50bae58baf895edc2a04d2b26 100644 (file)
@@ -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
index ffc347c7a014220268d0312f2304d03cd28b1e9e..32b146f5294bffcb5ee3f87ddf1ed40b4a109e54 100644 (file)
@@ -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.  */
index 5cfe1e48523132a3438ce551963a3afd9a160953..41e3d856912887f259da49f4658768656e9bfc55 100644 (file)
@@ -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 (file)
index 0000000..e2231e0
--- /dev/null
@@ -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>&);
+    };
+}