aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-08-09 15:20:40 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-08-09 15:20:40 +0000
commit8ec2ac347f9e853a0ff9a72084c86868d4d4c7f9 (patch)
treeacf22e7c13a5a79bb3589c0789a49c9610338ac3
parentb86c2124e270245e6d9b3a492142790dfe62a492 (diff)
downloadgcc-8ec2ac347f9e853a0ff9a72084c86868d4d4c7f9.zip
gcc-8ec2ac347f9e853a0ff9a72084c86868d4d4c7f9.tar.gz
gcc-8ec2ac347f9e853a0ff9a72084c86868d4d4c7f9.tar.bz2
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: r21643
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c40
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/explicit69.C2
3 files changed, 33 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4a1c42a..a84a1a9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+1998-08-09 Mark Mitchell <mark@markmitchell.com>
+
+ * pt.c (check_explicit_specialization): Don't abort on bogus
+ explicit instantiations.
+
1998-08-07 Mark Mitchell <mark@markmitchell.com>
* typeck.c (require_complete_type): Use complete_type_or_else.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f664caa..8e0983e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1205,19 +1205,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
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C b/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C
index f42b96d..671cf00 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/explicit69.C
@@ -1,2 +1,2 @@
//Build don't link:
-template class x {}; // ERROR - not a template instantiation XFAIL *-*-*
+template class x {}; // ERROR - not a template instantiation