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.
/* 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;
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
}
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;
/*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;
}
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.
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 "" }
{
bool bar(A& a)
{
- return a.foo == 0; // { dg-error "insufficient context" "" }
+ return a.foo == 0; // { dg-error "" "" }
}
};
--- /dev/null
+// 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" "" }
+}