]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/19258 (Incorrect access check for default argument)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Wed, 19 Jan 2005 14:46:35 +0000 (14:46 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Wed, 19 Jan 2005 14:46:35 +0000 (14:46 +0000)
PR c++/19258
* parser.c (cp_parser_late_parsing_default_args): Handle friend
defined in class.
* pt.c (push_access_scope, pop_access_scope): Likewise.

* g++.dg/lookup/friend6.C: New test.

From-SVN: r93898

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog

index e31e6db6f9b728d53a44ca6a1efb6930c3640e93..885d5d1178fd06a3d3bb21fe6bea2d16a61a797b 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-19  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/19258
+       * parser.c (cp_parser_late_parsing_default_args): Handle friend
+       defined in class.
+       * pt.c (push_access_scope, pop_access_scope): Likewise.
+
 2005-01-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/19263
index 2a3ce9258bf7686a5dd516694770297bc1a75f37..1bde1f9830b7a5d8df07c6b7b2be63db16c43677 100644 (file)
@@ -1,5 +1,6 @@
 /* C++ Parser.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004,
+   2005 Free Software Foundation, Inc.
    Written by Mark Mitchell <mark@codesourcery.com>.
 
    This file is part of GCC.
@@ -14843,10 +14844,12 @@ cp_parser_late_parsing_default_args (cp_parser *parser, tree fn)
       saved_local_variables_forbidden_p = parser->local_variables_forbidden_p;
       parser->local_variables_forbidden_p = true;
        /* Parse the assignment-expression.  */
-      if (DECL_CLASS_SCOPE_P (fn))
+      if (DECL_FRIEND_CONTEXT (fn))
+       push_nested_class (DECL_FRIEND_CONTEXT (fn));
+      else if (DECL_CLASS_SCOPE_P (fn))
        push_nested_class (DECL_CONTEXT (fn));
       TREE_PURPOSE (parameters) = cp_parser_assignment_expression (parser);
-      if (DECL_CLASS_SCOPE_P (fn))
+      if (DECL_FRIEND_CONTEXT (fn) || DECL_CLASS_SCOPE_P (fn))
        pop_nested_class ();
 
       /* If the token stream has not been completely used up, then
index 206c44935f3290754d74cc0c4c7431745314286d..8472bbb698f3024af6299593cbd26a68c5d348f6 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle parameterized types (templates) for GNU C++.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004  Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
    Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
    Rewritten by Jason Merrill (jason@cygnus.com).
 
@@ -180,7 +180,9 @@ push_access_scope (tree t)
                      || TREE_CODE (t) == VAR_DECL,
                      0);
 
-  if (DECL_CLASS_SCOPE_P (t))
+  if (DECL_FRIEND_CONTEXT (t))
+    push_nested_class (DECL_FRIEND_CONTEXT (t));
+  else if (DECL_CLASS_SCOPE_P (t))
     push_nested_class (DECL_CONTEXT (t));
   else
     push_to_top_level ();
@@ -205,7 +207,7 @@ pop_access_scope (tree t)
       saved_access_scope = TREE_CHAIN (saved_access_scope);
     }
 
-  if (DECL_CLASS_SCOPE_P (t))
+  if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t))
     pop_nested_class ();
   else
     pop_from_top_level ();
index c3fb9f3497a7264d523f2b2a1d44c786e83a981a..74841e8c016f1de7eddb5f806b222cace1a67bb7 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-19  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/19258
+       * g++.dg/lookup/friend6.C: New test.
+
 2005-01-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/15139