From: Mark Mitchell Date: Sun, 30 Aug 1998 11:46:44 +0000 (+0000) Subject: decl.c (grokfndecl): Issue error on declaration of friend templates with explicit... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7e2421f7228fb6b2927f83e396113b6723119823;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc79d485dd6..359516b1a8c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 1998-08-30 Mark Mitchell + * 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2d4fb134567..3da20575fea 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 friend void f()'. */ + 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); diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash23.C b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C new file mode 100644 index 00000000000..e4f5bee8772 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C @@ -0,0 +1,15 @@ +// Build don't link: + +template void foo(); +template class bar { + int i; + template friend void foo(); // ERROR - template-id +}; +template void foo() { + bar baz; baz.i = 1; + bar buz; buz.i = 1; +} +int main() { + foo(); + foo(); +}