decl.c (grokfndecl): Issue error on declaration of friend templates with explicit template arguments.

* decl.c (grokfndecl): Issue error on declaration of friend
	templates with explicit template arguments.

From-SVN: r22100
This commit is contained in:
Mark Mitchell 1998-08-30 11:46:44 +00:00 committed by Mark Mitchell
parent 8b5b8b7cc1
commit 7e2421f722
3 changed files with 26 additions and 0 deletions

View File

@ -1,5 +1,8 @@
1998-08-30 Mark Mitchell <mark@markmitchell.com>
* decl.c (grokfndecl): Issue error on declaration of friend
templates with explicit template arguments.
* pt.c (convert_template_argument): New function, split out
from...
(coerce_template_parms): Here.

View File

@ -7968,6 +7968,14 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
orig_declarator);
else
{
if (PROCESSING_REAL_TEMPLATE_DECL_P ())
{
/* Something like `template <class T> friend void f<T>()'. */
cp_error ("template-id `%D' in declaration of primary template",
orig_declarator);
return error_mark_node;
}
/* A friend declaration of the form friend void f<>(). Record
the information in the TEMPLATE_ID_EXPR. */
SET_DECL_IMPLICIT_INSTANTIATION (decl);

View File

@ -0,0 +1,15 @@
// Build don't link:
template <class A, class B> void foo();
template <class C> class bar {
int i;
template <class B> friend void foo<C,B>(); // ERROR - template-id
};
template <class A, class B> void foo() {
bar<A> baz; baz.i = 1;
bar<int> buz; buz.i = 1;
}
int main() {
foo<void,void>();
foo<int,void>();
}