This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/43621


push_scope doesn't actually push if the new scope is the same as the current one, so we need to check the return value.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 5484c0a645ad7cc4a05e1b2144fef59e17ab33db
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Apr 2 08:50:30 2010 -0400

    	PR c++/43621
    	* pt.c (maybe_update_decl_type): Check the return value from
    	push_scope.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3e2927c..0bd55e1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3720,15 +3720,17 @@ maybe_update_decl_type (tree orig_type, tree scope)
 	 TYPENAME_TYPEs and SCOPE_REFs that were previously dependent.  */
       tree args = current_template_args ();
       tree auto_node = type_uses_auto (type);
+      tree pushed;
       if (auto_node)
 	{
 	  tree auto_vec = make_tree_vec (1);
 	  TREE_VEC_ELT (auto_vec, 0) = auto_node;
 	  args = add_to_template_args (args, auto_vec);
 	}
-      push_scope (scope);
+      pushed = push_scope (scope);
       type = tsubst (type, args, tf_warning_or_error, NULL_TREE);
-      pop_scope (scope);
+      if (pushed)
+	pop_scope (scope);
     }
 
   if (type == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/template/error-recovery2.C b/gcc/testsuite/g++.dg/template/error-recovery2.C
new file mode 100644
index 0000000..d5ce123
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error-recovery2.C
@@ -0,0 +1,7 @@
+// PR c++/43621
+
+template <typename T>
+class A {
+  template <typename>
+  A<T> A<T>::f();		// { dg-error "extra qualification" }
+};

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]