diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-08-30 11:46:44 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-08-30 11:46:44 +0000 |
commit | 7e2421f7228fb6b2927f83e396113b6723119823 (patch) | |
tree | 1547491037630b1f135332c535f3c718946c7774 /gcc | |
parent | 8b5b8b7cc1d7f2fe67798c5b8648286309cabd73 (diff) | |
download | gcc-7e2421f7228fb6b2927f83e396113b6723119823.zip gcc-7e2421f7228fb6b2927f83e396113b6723119823.tar.gz gcc-7e2421f7228fb6b2927f83e396113b6723119823.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/crash23.C | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc79d48..359516b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2d4fb13..3da2057 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 <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); 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 0000000..e4f5bee --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C @@ -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>(); +} |