re PR c++/50344 (friend declaration confused by const qualifier)
authorJonathan Wakely <jwakely.gcc@gmail.com>
Thu, 22 Sep 2011 14:16:27 +0000 (14:16 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 22 Sep 2011 14:16:27 +0000 (14:16 +0000)
/cp
2011-09-22  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-22  Jonathan Wakely  <jwakely.gcc@gmail.com>
    Paolo Carlini  <paolo.carlini@oracle.com>

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

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r179088

gcc/cp/ChangeLog
gcc/cp/friend.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/friend52.C [new file with mode: 0644]

index 5123090..0dd01d9 100644 (file)
@@ -1,3 +1,10 @@
+2011-09-22  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.
+
 2011-09-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/50454
index 36fcca4..b6bd387 100644 (file)
@@ -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, bool complain)
       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
index 1942dfc..99cd2ea 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-22  Jonathan Wakely  <jwakely.gcc@gmail.com>
+           Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/50344
+       * g++.dg/template/friend52.C: New.
+
 2011-09-22  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * gcc.target/arm/cmp-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/friend52.C b/gcc/testsuite/g++.dg/template/friend52.C
new file mode 100644 (file)
index 0000000..d4fecd9
--- /dev/null
@@ -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;
+    }
+};