Commit 7d4bdeed by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (ANON_UNION_TYPE_P): Robustify.

	* cp-tree.h (ANON_UNION_TYPE_P): Robustify.
	* decl.c (make_typename_type): Don't issue an error if an
	immediate lookup fails; it migt be resolved later.
	* friend.c (is_friend): Add comment.
	* search.c (breadth_first_search): Add POSTFN and DATA
	parameters.  Tidy.  All callers changed.
	(lookup_field_queue_p): New function.
	(lookup_field_r): Likewise.
	(lookup_field_post): Likewise.
	(lookup_field): Use them, via breadth_first_search, instead of
	duplicating logic.
	(compute_access): Robustify.
	(lookup_fnfield_info): New structure.

From-SVN: r25607
parent 00512c3a
1999-03-05 Mark Mitchell <mark@markmitchell.com>
* cp-tree.h (ANON_UNION_TYPE_P): Robustify.
* decl.c (make_typename_type): Don't issue an error if an
immediate lookup fails; it migt be resolved later.
* friend.c (is_friend): Add comment.
* search.c (breadth_first_search): Add POSTFN and DATA
parameters. Tidy. All callers changed.
(lookup_field_queue_p): New function.
(lookup_field_r): Likewise.
(lookup_field_post): Likewise.
(lookup_field): Use them, via breadth_first_search, instead of
duplicating logic.
(compute_access): Robustify.
(lookup_fnfield_info): New structure.
1999-03-05 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (tsubst, case ARRAY_REF): Use tsubst_expr again.
......
......@@ -1708,9 +1708,12 @@ extern int flag_new_for_scope;
#define ANON_UNION_P(NODE) (DECL_NAME (NODE) == 0)
/* Nonzero if TYPE is an anonymous union type. */
/* Nonzero if TYPE is an anonymous union type. We're careful
accessing TYPE_IDENTIFIER because some built-in types, like
pointer-to-member types, do not have TYPE_NAME. */
#define ANON_UNION_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == UNION_TYPE \
&& TYPE_NAME (TYPE) \
&& ANON_AGGRNAME_P (TYPE_IDENTIFIER (TYPE)))
#define UNKNOWN_TYPE LANG_TYPE
......
......@@ -5192,34 +5192,29 @@ make_typename_type (context, name)
if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 0);
else
t = NULL_TREE;
if (t == NULL_TREE || TREE_CODE (t) != TEMPLATE_DECL
|| TREE_CODE (DECL_RESULT (t)) != TYPE_DECL)
{
cp_error ("no class template named `%#T' in `%#T'",
name, context);
return error_mark_node;
}
return lookup_template_class (t, TREE_OPERAND (fullname, 1),
NULL_TREE, context,
/*entering_scope=*/0);
if (t && DECL_CLASS_TEMPLATE_P (t))
return lookup_template_class (t, TREE_OPERAND (fullname, 1),
NULL_TREE, context,
/*entering_scope=*/0);
}
else
{
if (IS_AGGR_TYPE (context))
t = lookup_field (context, name, 0, 1);
else
t = NULL_TREE;
if (t == NULL_TREE)
{
cp_error ("no type named `%#T' in `%#T'", name, context);
return error_mark_node;
}
return TREE_TYPE (t);
if (t)
return TREE_TYPE (t);
}
}
......
......@@ -32,6 +32,8 @@ static void add_friends PROTO((tree, tree, tree));
/* Friend data structures are described in cp-tree.h. */
/* Returns non-zero if SUPPLICANT is a friend of TYPE. */
int
is_friend (type, supplicant)
tree type, supplicant;
......
// Build don't link:
void f()
{
union {
private:
int i;
} u;
u.i = 3; // ERROR - private
}
// Build don't link:
// Special g++ Options:
template <class T, bool B>
struct R {
struct X {};
};
template <class T, bool B = false>
struct S : public R <T, B> {
};
template <class T> void f()
{
S<T>::X();
}
template void f<int>();
// Build don't run:
// Special g++ Options:
struct B {
typedef int I;
};
template <class T>
struct D1 : public B {
};
template <class T>
struct D2 : public D1<T> {
I i;
};
template <>
struct D1<int> {
typedef double I;
};
template <class T>
void f(T);
template <>
void f(double) {}
int main()
{
D2<int> d2i;
f(d2i.i);
}
// Build don't link:
template <class T>
struct A
{
typedef T A_Type;
};
template <class U>
struct B : public A<U>
{
typename B<U>::A_Type Func();
};
template <class U>
typename B<U>::A_Type B<U>::Func()
{
}
......@@ -16,6 +16,6 @@ struct B : public A<U>
template <class U>
A<U>::A_Type B<U>::Func()
B<U>::A_Type B<U>::Func()
{
}
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