re PR c++/21592 (ICE in resolve_overloaded_unification/arg_assoc)

cp:
	PR c++/21592
	* pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
	with already looked up member functions.  Assert we're not
	returning a NON_DEPENDENT_EXPR with unknown type.
	* typeck.c (finish_class_member_access_expr):  We can get
	non-template-id-expr baselinks.  If the lookup finds a baselink,
	remember it even inside templates.
testsuite:
	PR c++/21592
	* g++.dg/template/dependent-expr1.C: Add new expected error.
	* g++.dg/template/dependent-expr2.C: Adjust error text.
	* g++.dg/template/overload6.C: New.

From-SVN: r105313
This commit is contained in:
Nathan Sidwell 2005-10-12 18:13:41 +00:00 committed by Nathan Sidwell
parent 3ce5fa4fa6
commit fdeff56396
7 changed files with 43 additions and 9 deletions

View file

@ -1,5 +1,13 @@
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21592
* pt.c (build_non_dependent_expr): Don't wrap a COMPONENT_REF
with already looked up member functions. Assert we're not
returning a NON_DEPENDENT_EXPR with unknown type.
* typeck.c (finish_class_member_access_expr): We can get
non-template-id-expr baselinks. If the lookup finds a baselink,
remember it even inside templates.
PR c++/23797
* parser.c (cp_parser_functional_cast): Cope when TYPE is not a
TYPE_DECL. Use dependent_type_p to check type.

View file

@ -12641,7 +12641,9 @@ build_non_dependent_expr (tree expr)
/* Preserve OVERLOADs; the functions must be available to resolve
types. */
inner_expr = (TREE_CODE (expr) == ADDR_EXPR ?
TREE_OPERAND (expr, 0) : expr);
TREE_OPERAND (expr, 0) :
TREE_CODE (expr) == COMPONENT_REF ?
TREE_OPERAND (expr, 1) : expr);
if (is_overloaded_fn (inner_expr)
|| TREE_CODE (inner_expr) == OFFSET_REF)
return expr;
@ -12680,6 +12682,9 @@ build_non_dependent_expr (tree expr)
TREE_OPERAND (expr, 0),
build_non_dependent_expr (TREE_OPERAND (expr, 1)));
/* If the type is unknown, it can't really be non-dependent */
gcc_assert (TREE_TYPE (expr) != unknown_type_node);
/* Otherwise, build a NON_DEPENDENT_EXPR.
REFERENCE_TYPEs are not stripped for expressions in templates

View file

@ -1904,11 +1904,8 @@ finish_class_member_access_expr (tree object, tree name)
}
if (BASELINK_P (name))
{
/* A member function that has already been looked up. */
gcc_assert (TREE_CODE (BASELINK_FUNCTIONS (name)) == TEMPLATE_ID_EXPR);
member = name;
}
/* A member function that has already been looked up. */
member = name;
else
{
bool is_template_id = false;
@ -2002,7 +1999,9 @@ finish_class_member_access_expr (tree object, tree name)
/*preserve_reference=*/false);
if (processing_template_decl && expr != error_mark_node)
return build_min_non_dep (COMPONENT_REF, expr,
orig_object, orig_name, NULL_TREE);
orig_object,
BASELINK_P (member) ? member : orig_name,
NULL_TREE);
return expr;
}

View file

@ -1,5 +1,10 @@
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/21592
* g++.dg/template/dependent-expr1.C: Add new expected error.
* g++.dg/template/dependent-expr2.C: Adjust error text.
* g++.dg/template/overload6.C: New.
PR c++/23797
* g++.dg/other/typename8.C: New.

View file

@ -19,7 +19,7 @@ namespace std
Foo (sizeof (x));
Foo (__alignof__ (I));
Foo (__alignof__ (x));
Foo (x->~I ());
Foo (x->~I ()); // { dg-error "" }
// Foo (typeid (I));
Foo (delete x); // { dg-error "" }
Foo (delete[] x); // { dg-error "" }

View file

@ -18,6 +18,6 @@ struct B
{
bool bar(A& a)
{
return a.foo == 0; // { dg-error "insufficient context" "" }
return a.foo == 0; // { dg-error "" "" }
}
};

View file

@ -0,0 +1,17 @@
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 12 Oct 2005 <nathan@codesourcery.com>
// PR 21592:ICE
// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
template<typename T> void unique(T,T);
struct A
{
int begin();
};
template<int> void foo()
{
unique(A().begin); // { dg-error "no matching function" "" }
}