typeck.c (build_class_member_access_expr): Handle COMPOUND_EXPR and COND_EXPR specially; fix error message output.
* typeck.c (build_class_member_access_expr): Handle COMPOUND_EXPR and COND_EXPR specially; fix error message output. * testsuite/g++.dg/inherit/cond1.C: New test. From-SVN: r56524
This commit is contained in:
parent
d65b1d77fd
commit
5b770a964a
4 changed files with 41 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
2002-08-22 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* typeck.c (build_class_member_access_expr): Handle COMPOUND_EXPR
|
||||
and COND_EXPR specially; fix error message output.
|
||||
|
||||
2002-08-22 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* pt.c (tsubst_expr): RETURN_EXPR is now RETURN_STMT_EXPR.
|
||||
|
|
|
@ -1859,6 +1859,27 @@ build_class_member_access_expr (tree object, tree member,
|
|||
my_friendly_assert (DECL_P (member) || BASELINK_P (member),
|
||||
20020801);
|
||||
|
||||
/* Transform `(a, b).x' into `a, b.x' and `(a ? b : c).x' into
|
||||
`a ? b.x : c.x'. These transformations should not really be
|
||||
necessary, but they are. */
|
||||
if (TREE_CODE (object) == COMPOUND_EXPR)
|
||||
{
|
||||
result = build_class_member_access_expr (TREE_OPERAND (object, 1),
|
||||
member, access_path,
|
||||
preserve_reference);
|
||||
return build (COMPOUND_EXPR, TREE_TYPE (result),
|
||||
TREE_OPERAND (object, 0), result);
|
||||
}
|
||||
else if (TREE_CODE (object) == COND_EXPR)
|
||||
return (build_conditional_expr
|
||||
(TREE_OPERAND (object, 0),
|
||||
build_class_member_access_expr (TREE_OPERAND (object, 1),
|
||||
member, access_path,
|
||||
preserve_reference),
|
||||
build_class_member_access_expr (TREE_OPERAND (object, 2),
|
||||
member, access_path,
|
||||
preserve_reference)));
|
||||
|
||||
/* [expr.ref]
|
||||
|
||||
The type of the first expression shall be "class object" (of a
|
||||
|
@ -2135,7 +2156,7 @@ finish_class_member_access_expr (tree object, tree name)
|
|||
if (TREE_CODE (scope) == NAMESPACE_DECL)
|
||||
{
|
||||
error ("`%D::%D' is not a member of `%T'",
|
||||
scope, member, object_type);
|
||||
scope, name, object_type);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2002-08-22 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* testsuite/g++.dg/inherit/cond1.C: New test.
|
||||
|
||||
2002-08-22 Geoffrey Keating <geoffk@redhat.com>
|
||||
|
||||
* gcc.dg/noncompile/incomplete-1.c: New test.
|
||||
|
|
10
gcc/testsuite/g++.dg/inherit/cond1.C
Normal file
10
gcc/testsuite/g++.dg/inherit/cond1.C
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Origin: jason@redhat.com
|
||||
// { dg-do compile }
|
||||
|
||||
struct A { A(); A(const A&); int i; };
|
||||
struct B: public A { };
|
||||
|
||||
int f (bool b, A& ar, B& br)
|
||||
{
|
||||
return (b?ar:br).i;
|
||||
}
|
Loading…
Add table
Reference in a new issue