aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-09-27 23:31:57 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-09-27 23:31:57 +0000
commitc43e95f8f5f67265f05633813f3950624bb4064b (patch)
tree1d48bc0ddc17e9104af7209393174573d9ace1ff
parent57f0d086d592e6c9bb44c330939b9dda63d24934 (diff)
downloadgcc-c43e95f8f5f67265f05633813f3950624bb4064b.zip
gcc-c43e95f8f5f67265f05633813f3950624bb4064b.tar.gz
gcc-c43e95f8f5f67265f05633813f3950624bb4064b.tar.bz2
re PR c++/22147 (ICE in get_bindings)
PR c++/22147 * name-lookup.c (maybe_process_template_type_declaration): Don't treat forward declarations of classes as templates just because we're processing_template_decl. * pt.c (tsubst_decl): Clear DECL_TEMPLATE_INFO for friend functions. PR c++/22147 * g++.dg/template/friend37.C: New test. * g++.dg/parse/crash28.C: Adjust error markers. From-SVN: r104713
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/name-lookup.c5
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/parse/crash28.C4
-rw-r--r--gcc/testsuite/g++.dg/template/friend37.C15
6 files changed, 39 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bdc7237..0c429cf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2005-09-27 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/22147
+ * name-lookup.c (maybe_process_template_type_declaration): Don't
+ treat forward declarations of classes as templates just because
+ we're processing_template_decl.
+ * pt.c (tsubst_decl): Clear DECL_TEMPLATE_INFO for friend
+ functions.
+
2005-09-26 Jason Merrill <jason@redhat.com>
PR c++/13764
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index f25a334..29e5f2b 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -4689,6 +4689,11 @@ maybe_process_template_type_declaration (tree type, int is_friend,
is a forward-declaration of `A'. */
;
+ else if (b->kind == sk_namespace
+ && current_binding_level->kind != sk_namespace)
+ /* If this new type is being injected into a containing scope,
+ then it's not a template type. */
+ ;
else
{
gcc_assert (IS_AGGR_TYPE (type) || TREE_CODE (type) == ENUMERAL_TYPE);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index be2f031..1217580 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6510,6 +6510,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
&& !uses_template_parms (argvec))
tsubst_default_arguments (r);
}
+ else
+ DECL_TEMPLATE_INFO (r) = NULL_TREE;
/* Copy the list of befriending classes. */
for (friends = &DECL_BEFRIENDING_CLASSES (r);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e6375b5..74cb23f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-09-27 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/22147
+ * g++.dg/template/friend37.C: New test.
+ * g++.dg/parse/crash28.C: Adjust error markers.
+
2005-09-27 Jakub Jelinek <jakub@redhat.com>
PR fortran/18518
diff --git a/gcc/testsuite/g++.dg/parse/crash28.C b/gcc/testsuite/g++.dg/parse/crash28.C
index 9c38f89..bc49165 100644
--- a/gcc/testsuite/g++.dg/parse/crash28.C
+++ b/gcc/testsuite/g++.dg/parse/crash28.C
@@ -6,9 +6,9 @@
// Volker Reichelt <reichelt@gcc.gnu.org>
template <class _Tp> class insert_iterator<slist<_Tp> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
-template <class _Value> class insert_iterator<int > { // { dg-error "template parameters not used|_Value" }
+template <class _Value> class insert_iterator<int > { // { dg-error "template" }
hash_set<_Value>; // { dg-error "no type|expected" }
};
template<int> struct A<X<> > {}; // { dg-error "not a template|not declared in this scope|expected unqualified-id|extra" }
-struct A {}; // { dg-error "template argument required" }
+struct A {};
diff --git a/gcc/testsuite/g++.dg/template/friend37.C b/gcc/testsuite/g++.dg/template/friend37.C
new file mode 100644
index 0000000..7c86829
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend37.C
@@ -0,0 +1,15 @@
+// PR c++/22147
+
+template<typename> struct A;
+
+template<typename T> void foo(A<T>* p) { *p; }
+
+template<typename> struct A
+{
+ friend void foo<class X>(A<X>*);
+};
+
+void bar()
+{
+ foo<int>(0);
+}