semantics.c (finish_decltype_type): Simplify handling of unknown type.
* semantics.c (finish_decltype_type): Simplify handling of unknown type. From-SVN: r172140
This commit is contained in:
parent
5b97c77f8c
commit
6cdb14286d
@ -1,5 +1,8 @@
|
|||||||
2011-04-07 Jason Merrill <jason@redhat.com>
|
2011-04-07 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* semantics.c (finish_decltype_type): Simplify handling of unknown
|
||||||
|
type.
|
||||||
|
|
||||||
* semantics.c (finish_decltype_type): Add complain parm.
|
* semantics.c (finish_decltype_type): Add complain parm.
|
||||||
* cp-tree.h: Adjust.
|
* cp-tree.h: Adjust.
|
||||||
* parser.c (cp_parser_decltype): Adjust.
|
* parser.c (cp_parser_decltype): Adjust.
|
||||||
|
@ -4788,7 +4788,6 @@ tree
|
|||||||
finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
||||||
tsubst_flags_t complain)
|
tsubst_flags_t complain)
|
||||||
{
|
{
|
||||||
tree orig_expr = expr;
|
|
||||||
tree type = NULL_TREE;
|
tree type = NULL_TREE;
|
||||||
|
|
||||||
if (!expr || error_operand_p (expr))
|
if (!expr || error_operand_p (expr))
|
||||||
@ -4826,6 +4825,13 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
|||||||
|
|
||||||
expr = resolve_nondeduced_context (expr);
|
expr = resolve_nondeduced_context (expr);
|
||||||
|
|
||||||
|
if (type_unknown_p (expr))
|
||||||
|
{
|
||||||
|
if (complain & tf_error)
|
||||||
|
error ("decltype cannot resolve address of overloaded function");
|
||||||
|
return error_mark_node;
|
||||||
|
}
|
||||||
|
|
||||||
/* To get the size of a static data member declared as an array of
|
/* To get the size of a static data member declared as an array of
|
||||||
unknown bound, we need to instantiate it. */
|
unknown bound, we need to instantiate it. */
|
||||||
if (TREE_CODE (expr) == VAR_DECL
|
if (TREE_CODE (expr) == VAR_DECL
|
||||||
@ -4855,28 +4861,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
|||||||
expr = TREE_OPERAND (expr, 1);
|
expr = TREE_OPERAND (expr, 1);
|
||||||
|
|
||||||
if (TREE_CODE (expr) == BASELINK)
|
if (TREE_CODE (expr) == BASELINK)
|
||||||
/* See through BASELINK nodes to the underlying functions. */
|
/* See through BASELINK nodes to the underlying function. */
|
||||||
expr = BASELINK_FUNCTIONS (expr);
|
expr = BASELINK_FUNCTIONS (expr);
|
||||||
|
|
||||||
if (TREE_CODE (expr) == TEMPLATE_ID_EXPR)
|
|
||||||
expr = TREE_OPERAND (expr, 0);
|
|
||||||
|
|
||||||
if (TREE_CODE (expr) == OVERLOAD)
|
|
||||||
{
|
|
||||||
if (OVL_CHAIN (expr)
|
|
||||||
|| TREE_CODE (OVL_FUNCTION (expr)) == TEMPLATE_DECL)
|
|
||||||
{
|
|
||||||
if (complain & tf_error)
|
|
||||||
error ("%qE refers to a set of overloaded functions",
|
|
||||||
orig_expr);
|
|
||||||
return error_mark_node;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* An overload set containing only one function: just look
|
|
||||||
at that function. */
|
|
||||||
expr = OVL_FUNCTION (expr);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (TREE_CODE (expr))
|
switch (TREE_CODE (expr))
|
||||||
{
|
{
|
||||||
case FIELD_DECL:
|
case FIELD_DECL:
|
||||||
@ -4918,10 +4905,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gcc_assert (TYPE_P (expr) || DECL_P (expr)
|
gcc_unreachable ();
|
||||||
|| TREE_CODE (expr) == SCOPE_REF);
|
|
||||||
if (complain & tf_error)
|
|
||||||
error ("argument to decltype must be an expression");
|
|
||||||
return error_mark_node;
|
return error_mark_node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4957,13 +4941,6 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!type || type == unknown_type_node)
|
|
||||||
{
|
|
||||||
if (complain & tf_error)
|
|
||||||
error ("type of %qE is unknown", expr);
|
|
||||||
return error_mark_node;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user