re PR c++/30659 (ICE in undefined template)
authorPaolo Carlini <pcarlini@suse.de>
Mon, 29 Oct 2007 00:17:10 +0000 (00:17 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 29 Oct 2007 00:17:10 +0000 (00:17 +0000)
cp/
2007-10-28  Paolo Carlini  <pcarlini@suse.de>
    Mark Mitchell  <mark@codesourcery.com>

PR c++/30659
* pt.c (do_decl_instantiation): If the VAR_DECL is not a
class member error out and return.

testsuite/
2007-10-28  Paolo Carlini  <pcarlini@suse.de>
    Mark Mitchell  <mark@codesourcery.com>

PR c++/30659
* g++.dg/template/crash71.C: New.

Co-Authored-By: Mark Mitchell <mark@codesourcery.com>
From-SVN: r129710

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

index 2857d4b35d265b20acb095ef3abc3580aadb36d6..8e2323bb8bb17764e17deb2272284e8cc60afee8 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-28  Paolo Carlini  <pcarlini@suse.de>
+           Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/30659
+       * pt.c (do_decl_instantiation): If the VAR_DECL is not a
+       class member error out and return.
+
 2007-10-27  Jakub Jelinek  <jakub@redhat.com>
 
        * error.c (reinit_cxx_pp): Initialize cxx_pp->enclosing_scope
index 9193f487f9021cbdec03e1777560c045b4be7715..3e8f6e585dae3a7b10193fd92d65ebf6baa3bc51 100644 (file)
@@ -13882,6 +13882,11 @@ do_decl_instantiation (tree decl, tree storage)
         VAR_DECLs so we do the lookup here.  Probably, grokdeclarator
         should handle VAR_DECLs as it currently handles
         FUNCTION_DECLs.  */
+      if (!DECL_CLASS_SCOPE_P (decl))
+       {
+         error ("%qD is not a static data member of a class template", decl);
+         return;
+       }
       result = lookup_field (DECL_CONTEXT (decl), DECL_NAME (decl), 0, false);
       if (!result || TREE_CODE (result) != VAR_DECL)
        {
index 66168c796ba24cc80c029290569fb5bfc502485f..cecd5f0ee1956f09abb3d7579f7f20668cd75058 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-28  Paolo Carlini  <pcarlini@suse.de>
+           Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/30659
+       * g++.dg/template/crash71.C: New.
+
 2007-10-28  Tobias Schlüter  <tobi@gcc.gnu.org>
 
        PR fortran/32147
diff --git a/gcc/testsuite/g++.dg/template/crash71.C b/gcc/testsuite/g++.dg/template/crash71.C
new file mode 100644 (file)
index 0000000..86aa152
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/30659
+
+extern "C" template A<char> foo(); // { dg-error "forbids|static data|expected" }