Commit 73452ce7 by Dodji Seketeli Committed by Dodji Seketeli

re PR c++/48838 (valid template code does not compile)

Fix PR c++/48838

gcc/cp

	PR c++/48838
	* cp-tree.h (non_static_member_function_p): Declare new function.
	* tree.c (non_static_member_function_p): Define it.
	* semantics.c (finish_call_expr): Use it.

gcc/testsuite

	PR c++/48838
	* g++.dg/template/member9.C: New test case.

From-SVN: r173473
parent 155b6176
2011-05-06 Dodji Seketeli <dodji@redhat.com>
PR c++/48838
* cp-tree.h (non_static_member_function_p): Declare new function.
* tree.c (non_static_member_function_p): Define it.
* semantics.c (finish_call_expr): Use it.
2011-05-05 Nathan Froyd <froydnj@codesourcery.com> 2011-05-05 Nathan Froyd <froydnj@codesourcery.com>
* decl.c (finish_case_label): Omit the loc argument to * decl.c (finish_case_label): Omit the loc argument to
......
...@@ -5432,6 +5432,7 @@ extern tree get_fns (tree); ...@@ -5432,6 +5432,7 @@ extern tree get_fns (tree);
extern tree get_first_fn (tree); extern tree get_first_fn (tree);
extern tree ovl_cons (tree, tree); extern tree ovl_cons (tree, tree);
extern tree build_overload (tree, tree); extern tree build_overload (tree, tree);
extern bool non_static_member_function_p (tree);
extern const char *cxx_printable_name (tree, int); extern const char *cxx_printable_name (tree, int);
extern const char *cxx_printable_name_translate (tree, int); extern const char *cxx_printable_name_translate (tree, int);
extern tree build_exception_variant (tree, tree); extern tree build_exception_variant (tree, tree);
......
...@@ -2039,8 +2039,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, ...@@ -2039,8 +2039,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
is not included in *ARGS even though it is considered to is not included in *ARGS even though it is considered to
be part of the list of arguments. Note that this is be part of the list of arguments. Note that this is
related to CWG issues 515 and 1005. */ related to CWG issues 515 and 1005. */
|| (((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) || (non_static_member_function_p (fn)
|| BASELINK_P (fn))
&& current_class_ref && current_class_ref
&& type_dependent_expression_p (current_class_ref))) && type_dependent_expression_p (current_class_ref)))
{ {
......
...@@ -1480,6 +1480,22 @@ build_overload (tree decl, tree chain) ...@@ -1480,6 +1480,22 @@ build_overload (tree decl, tree chain)
return ovl_cons (decl, chain); return ovl_cons (decl, chain);
} }
/* Return TRUE if FN is a non-static member function, FALSE otherwise.
This function looks into BASELINK and OVERLOAD nodes. */
bool
non_static_member_function_p (tree fn)
{
if (fn == NULL_TREE)
return false;
if (is_overloaded_fn (fn))
fn = get_first_fn (fn);
return (DECL_P (fn)
&& DECL_NONSTATIC_MEMBER_FUNCTION_P (fn));
}
#define PRINT_RING_SIZE 4 #define PRINT_RING_SIZE 4
......
2011-05-06 Dodji Seketeli <dodji@redhat.com>
PR c++/48838
* g++.dg/template/member9.C: New test case.
2011-05-05 Eric Botcazou <ebotcazou@adacore.com> 2011-05-05 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr29.ad[sb]: New test. * gnat.dg/discr29.ad[sb]: New test.
......
// Origin PR c++/48838
// { dg-do compile }
class DUChainItemSystem
{
public:
template<class T>
void registerTypeClass();
static DUChainItemSystem& self();
};
template<class T>
struct DUChainItemRegistrator
{
DUChainItemRegistrator()
{
DUChainItemSystem::self().registerTypeClass<T>();
}
};
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