public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 50344
@ 2011-09-21 16:00 Paolo Carlini
  2011-09-21 17:45 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2011-09-21 16:00 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hi,

basing on [class.friend] (11.3/3) in C++11 I think Jon is right that 
cv-qualification should be ok in a friend declaration. I'm not sure, 
however, if we want to somehow allow that also in c++98 mode... Tested 
x86_64-linux.

Ok?

Thanks,
Paolo.

///////////////////

[-- Attachment #2: CL_50344 --]
[-- Type: text/plain, Size: 368 bytes --]

/cp
2011-09-21  Paolo Carlini  <paolo.carlini@oracle.com>
	    Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR c++/50344
	* friend.c (make_friend_class): In c++0x mode, cv-qualification is
	ok in a friend declaration.

/cp
2011-09-21  Paolo Carlini  <paolo.carlini@oracle.com>
	    Jonathan Wakely  <jwakely.gcc@gmail.com>

	PR c++/50344
	* g++.dg/cpp0x/friend3.C: New.

[-- Attachment #3: patch_50344 --]
[-- Type: text/plain, Size: 1157 bytes --]

Index: testsuite/g++.dg/cpp0x/friend3.C
===================================================================
--- testsuite/g++.dg/cpp0x/friend3.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/friend3.C	(revision 0)
@@ -0,0 +1,17 @@
+// PR c++/50344
+// { dg-options -std=c++0x }
+
+template <typename T> class C
+{
+   friend T;
+   int i;
+};
+
+struct S
+{
+    int f()
+    {
+       C<const S> c;
+       return c.i;
+    }
+};
Index: cp/friend.c
===================================================================
--- cp/friend.c	(revision 179049)
+++ cp/friend.c	(working copy)
@@ -1,6 +1,6 @@
 /* Help friends in C++.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008, 2010  Free Software Foundation, Inc.
+   2007, 2008, 2010, 2011  Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -236,6 +236,8 @@ make_friend_class (tree type, tree friend_type, bo
 		 "invalid type %qT declared %<friend%>", friend_type);
       return;
     }
+  else if (cxx_dialect >= cxx0x)
+    friend_type = cv_unqualified (friend_type);
 
   if (friend_depth)
     /* If the TYPE is a template then it makes sense for it to be

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 50344
  2011-09-21 16:00 [C++ Patch] PR 50344 Paolo Carlini
@ 2011-09-21 17:45 ` Jason Merrill
  2011-09-21 19:02   ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2011-09-21 17:45 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

On 09/21/2011 11:12 AM, Paolo Carlini wrote:
> basing on [class.friend] (11.3/3) in C++11 I think Jon is right that
> cv-qualification should be ok in a friend declaration. I'm not sure,
> however, if we want to somehow allow that also in c++98 mode...

I think we do.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 50344
  2011-09-21 17:45 ` Jason Merrill
@ 2011-09-21 19:02   ` Paolo Carlini
  2011-09-22 14:21     ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2011-09-21 19:02 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 164 bytes --]

On 09/21/2011 06:55 PM, Jason Merrill wrote:
> I think we do.
Agreed. I'm finishing testing the below, Ok if it passes?

Thanks,
Paolo.

//////////////////////////

[-- Attachment #2: CL_50344_2 --]
[-- Type: text/plain, Size: 364 bytes --]

/cp
2011-09-21  Jonathan Wakely  <jwakely.gcc@gmail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50344
	* friend.c (make_friend_class): cv-qualification is ok in a
	friend declaration.

/testsuite
2011-09-21  Jonathan Wakely  <jwakely.gcc@gmail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50344
	* g++.dg/template/friend52.C: New.

[-- Attachment #3: patch_50344_2 --]
[-- Type: text/plain, Size: 1136 bytes --]

Index: testsuite/g++.dg/template/friend52.C
===================================================================
--- testsuite/g++.dg/template/friend52.C	(revision 0)
+++ testsuite/g++.dg/template/friend52.C	(revision 0)
@@ -0,0 +1,17 @@
+// PR c++/50344
+// { dg-options "" }
+
+template <typename T> class C
+{
+   friend T;
+   int i;
+};
+
+struct S
+{
+    int f()
+    {
+       C<const S> c;
+       return c.i;
+    }
+};
Index: cp/friend.c
===================================================================
--- cp/friend.c	(revision 179052)
+++ cp/friend.c	(working copy)
@@ -1,6 +1,6 @@
 /* Help friends in C++.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008, 2010  Free Software Foundation, Inc.
+   2007, 2008, 2010, 2011  Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -237,6 +237,8 @@ make_friend_class (tree type, tree friend_type, bo
       return;
     }
 
+  friend_type = cv_unqualified (friend_type);
+
   if (friend_depth)
     /* If the TYPE is a template then it makes sense for it to be
        friends with itself; this means that each instantiation is

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 50344
  2011-09-21 19:02   ` Paolo Carlini
@ 2011-09-22 14:21     ` Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2011-09-22 14:21 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-22 13:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 16:00 [C++ Patch] PR 50344 Paolo Carlini
2011-09-21 17:45 ` Jason Merrill
2011-09-21 19:02   ` Paolo Carlini
2011-09-22 14:21     ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).