This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/29363 (error-recovery with type definition after use)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 13 Nov 2009 13:46:03 -0500
- Subject: C++ PATCH for c++/29363 (error-recovery with type definition after use)
There doesn't seem to be any reason to set TYPE_STUB_DECL in the various
callers of create_implicit_typedef rather than in that function itself.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit 1cb6ff5934a8c34e54b2c483e2f62cd737cadd50
Author: Jason Merrill <jason@redhat.com>
Date: Fri Nov 13 12:42:27 2009 -0500
PR c++/29363
* decl.c (create_implicit_typedef): Set TYPE_STUB_DECL here.
(cxx_init_decl_processing): Not here.
* name-lookup.c (pushtag): Or here.
* pt.c (lookup_template_class): Or here.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e23634f..0375dd5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -849,6 +849,7 @@ create_implicit_typedef (tree name, tree type)
amongst these. */
SET_DECL_IMPLICIT_TYPEDEF_P (decl);
TYPE_NAME (type) = decl;
+ TYPE_STUB_DECL (type) = decl;
return decl;
}
@@ -3456,7 +3457,6 @@ cxx_init_decl_processing (void)
bad_alloc_decl
= create_implicit_typedef (bad_alloc_id, bad_alloc_type_node);
DECL_CONTEXT (bad_alloc_decl) = current_namespace;
- TYPE_STUB_DECL (bad_alloc_type_node) = bad_alloc_decl;
pop_namespace ();
ptr_ftype_sizetype
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 14f9787..6b8dcc7 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -5288,7 +5288,6 @@ pushtag (tree name, tree type, tag_scope scope)
decl = TYPE_NAME (type);
gcc_assert (TREE_CODE (decl) == TYPE_DECL);
- TYPE_STUB_DECL (type) = decl;
/* Set type visibility now if this is a forward declaration. */
TREE_PUBLIC (decl) = 1;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c799368..540f577 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6371,7 +6371,6 @@ lookup_template_class (tree d1,
type_decl = create_implicit_typedef (DECL_NAME (gen_tmpl), t);
DECL_CONTEXT (type_decl) = TYPE_CONTEXT (t);
- TYPE_STUB_DECL (t) = type_decl;
DECL_SOURCE_LOCATION (type_decl)
= DECL_SOURCE_LOCATION (TYPE_STUB_DECL (template_type));
}
diff --git a/gcc/testsuite/g++.dg/template/error43.C b/gcc/testsuite/g++.dg/template/error43.C
new file mode 100644
index 0000000..876e018
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error43.C
@@ -0,0 +1,9 @@
+// PR c++/29363
+
+template<int> void foo()
+{
+ throw A(); // { dg-message "declar" }
+ struct A {} a;
+}
+
+template void foo<0>(); // { dg-message "instantiated" }