This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

fix for using explicit on a friend decl (of a ctor, still illegal)


This makes the compiler give an error when a user tries something like

	class foo { public: foo(); };
	class bar { public: friend explicit foo::foo(); };

(Already checked into egcs.)

B

1998-10-26  Brendan Kehoe  <brendan@cygnus.com>

	* decl.c (grokdeclarator): Disallow `explicit' in a friend declaration.

--- decl.c	1998/10/25 23:15:00	1.244
+++ decl.c	1998/10/26 19:38:48
@@ -9235,6 +9235,10 @@ grokdeclarator (declarator, declspecs, d
   friendp = RIDBIT_SETP (RID_FRIEND, specbits);
   RIDBIT_RESET (RID_FRIEND, specbits);
 
+  /* $7.1.2, Function specifiers */
+  if (friendp && explicitp)
+    error ("only declarations of constructors can be `explicit'");
+
   if (RIDBIT_SETP (RID_MUTABLE, specbits))
     {
       if (decl_context == PARM)

-- 
Brendan Kehoe                                               brendan@cygnus.com
Cygnus Solutions, Sunnyvale, CA                                +1 408 542 9600

Web page: http://www.zen.org/~brendan/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]