Commit 0f399e5f by Kriang Lerdsuwanakij Committed by Kriang Lerdsuwanakij

pt.c (push_access_scope_real): Call push_to_top_level for function in namespace scope.

	* pt.c (push_access_scope_real): Call push_to_top_level for
	function in namespace scope.
	(pop_access_scope): Call pop_from_top_level for function in
	namespace scope.

	* g++.dg/template/friend14.C: New test.

From-SVN: r61114
parent c456a45a
2003-01-09 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* pt.c (push_access_scope_real): Call push_to_top_level for
function in namespace scope.
(pop_access_scope): Call pop_from_top_level for function in
namespace scope.
2003-01-09 Jakub Jelinek <jakub@redhat.com> 2003-01-09 Jakub Jelinek <jakub@redhat.com>
* decl.c (start_decl): Don't set DECL_COMMON for __thread variables. * decl.c (start_decl): Don't set DECL_COMMON for __thread variables.
......
...@@ -209,16 +209,21 @@ push_access_scope_real (t, args, context) ...@@ -209,16 +209,21 @@ push_access_scope_real (t, args, context)
if (spec) if (spec)
t = spec; t = spec;
} }
saved_access_scope = tree_cons
(NULL_TREE, current_function_decl, saved_access_scope);
current_function_decl = t;
} }
if (!context) if (!context)
context = DECL_CONTEXT (t); context = DECL_CONTEXT (t);
if (context && TYPE_P (context)) if (context && TYPE_P (context))
push_nested_class (context, 2); push_nested_class (context, 2);
else
push_to_top_level ();
if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t))
{
saved_access_scope = tree_cons
(NULL_TREE, current_function_decl, saved_access_scope);
current_function_decl = t;
}
} }
/* Like push_access_scope_real, but always uses DECL_CONTEXT. */ /* Like push_access_scope_real, but always uses DECL_CONTEXT. */
...@@ -237,14 +242,16 @@ void ...@@ -237,14 +242,16 @@ void
pop_access_scope (t) pop_access_scope (t)
tree t; tree t;
{ {
if (DECL_CLASS_SCOPE_P (t))
pop_nested_class ();
if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t)) if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t))
{ {
current_function_decl = TREE_VALUE (saved_access_scope); current_function_decl = TREE_VALUE (saved_access_scope);
saved_access_scope = TREE_CHAIN (saved_access_scope); saved_access_scope = TREE_CHAIN (saved_access_scope);
} }
if (DECL_CLASS_SCOPE_P (t))
pop_nested_class ();
else
pop_from_top_level ();
} }
/* Do any processing required when DECL (a member template /* Do any processing required when DECL (a member template
......
2003-01-09 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* g++.dg/template/friend14.C: New test.
2003-01-09 Eric Botcazou <ebotcazou@libertysurf.fr> 2003-01-09 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/old-style-asm-1.c: New test. * gcc.dg/old-style-asm-1.c: New test.
......
// { dg-do compile }
// Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
// Perform access checking to parameter and return type of
// function template correctly when the template is friend.
template <class T> class O {
struct I { I (int); };
template <class T_>
friend typename O<T_>::I f ();
};
template <class T_>
typename O<T_>::I f () { return 1; }
struct X {
void g() { f<int>(); }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment