OSDN Git Service

PR c++/43076
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Mar 2010 22:34:02 +0000 (22:34 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Mar 2010 22:34:02 +0000 (22:34 +0000)
* pt.c (push_template_decl_real): Deal better with running out of
scopes before running out of template parms.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157842 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2f6ae04..9138ee1 100644 (file)
@@ -1,5 +1,9 @@
 2010-03-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43076
+       * pt.c (push_template_decl_real): Deal better with running out of
+       scopes before running out of template parms.
+
        PR c++/41185
        PR c++/41786
        * parser.c (cp_parser_direct_declarator): Don't allow VLAs in
index a58dba2..a8e1b78 100644 (file)
@@ -4548,6 +4548,9 @@ push_template_decl_real (tree decl, bool is_friend)
 
            if (current == decl)
              current = ctx;
+           else if (current == NULL_TREE)
+             /* Can happen in erroneous input.  */
+             break;
            else
              current = (TYPE_P (current)
                         ? TYPE_CONTEXT (current)
index a561219..818dbde 100644 (file)
@@ -1,5 +1,8 @@
 2010-03-30  Jason Merrill  <jason@redhat.com>
 
+       PR c++/43076
+       * g++.dg/template/error-recovery1.C: New.
+
        PR c++/41786
        * g++.dg/parse/ambig5.C: New.
 
diff --git a/gcc/testsuite/g++.dg/template/error-recovery1.C b/gcc/testsuite/g++.dg/template/error-recovery1.C
new file mode 100644 (file)
index 0000000..ef9dc14
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/43076
+
+struct S;
+template < typename > struct T
+{
+  template < typename >
+  template < bool > struct T < S > // { dg-error "" }
+  {
+    void f () {                        // { dg-error "" }