decl.c (grokfndecl): Issue error on declaration of friend templates with explicit...
authorMark Mitchell <mark@markmitchell.com>
Sun, 30 Aug 1998 11:46:44 +0000 (11:46 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 30 Aug 1998 11:46:44 +0000 (11:46 +0000)
* decl.c (grokfndecl): Issue error on declaration of friend
templates with explicit template arguments.

From-SVN: r22100

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.old-deja/g++.pt/crash23.C [new file with mode: 0644]

index fc79d485dd611be6c9d46d3fbe755a23cf055b6a..359516b1a8c53ec49b8e6c85b41c546efc8e39c9 100644 (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.
index 2d4fb1345674e753d17b1d3a9b5ccf257275b83a..3da20575fead7cc86d82eb7928f7a0cae07ffdc6 100644 (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);
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 (file)
index 0000000..e4f5bee
--- /dev/null
@@ -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>();
+}