diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-08-17 09:07:26 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-08-17 09:07:26 +0000 |
commit | 4217bb1376724442134b9d04debd21db1ee906f9 (patch) | |
tree | a6ce88aebf28168e50e966d70e7dec88f1e81cab /gcc | |
parent | 5aaf204851516cb292f92a9317c92abee0c55cf0 (diff) | |
download | gcc-4217bb1376724442134b9d04debd21db1ee906f9.tar.gz |
pt.c (check_explicit_specialization): Don't abort on bogus explicit instantiations.
* pt.c (check_explicit_specialization): Don't abort on bogus
explicit instantiations.
From-SVN: r21780
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 40 |
2 files changed, 32 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ad847f4b839..c0b985cdbe4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-08-17 Mark Mitchell <mark@markmitchell.com> + + * pt.c (check_explicit_specialization): Don't abort on bogus + explicit instantiations. + 1998-08-14 Jason Merrill <jason@yorick.cygnus.com> * rtti.c (get_tinfo_fn): Don't mess with the context for now. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9c724314ccf..5c65140cbe7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1107,19 +1107,33 @@ check_explicit_specialization (declarator, decl, template_count, flags) if (ctype != NULL_TREE && TYPE_BEING_DEFINED (ctype)) { - /* Since finish_struct_1 has not been called yet, we - can't call lookup_fnfields. We note that this - template is a specialization, and proceed, letting - finish_struct fix this up later. */ - tree ti = perm_tree_cons (NULL_TREE, - TREE_OPERAND (declarator, 1), - NULL_TREE); - TI_PENDING_SPECIALIZATION_FLAG (ti) = 1; - DECL_TEMPLATE_INFO (decl) = ti; - /* This should not be an instantiation; explicit - instantiation directives can only occur at the top - level. */ - my_friendly_assert (!explicit_instantiation, 0); + if (!explicit_instantiation) + { + /* Since finish_struct_1 has not been called yet, we + can't call lookup_fnfields. We note that this + template is a specialization, and proceed, letting + finish_struct fix this up later. */ + tree ti = perm_tree_cons (NULL_TREE, + TREE_OPERAND (declarator, 1), + NULL_TREE); + TI_PENDING_SPECIALIZATION_FLAG (ti) = 1; + DECL_TEMPLATE_INFO (decl) = ti; + } + else + /* It's not legal to write an explicit instantiation in + class scope, e.g.: + + class C { template void f(); } + + This case is caught by the parser. However, on + something like: + + template class C { void f(); }; + + (which is illegal) we can get here. The error will be + issued later. */ + ; + return decl; } else if (ctype != NULL_TREE |