class.c (instantiate_type): Handle object-relative template-id.

* class.c (instantiate_type): Handle object-relative template-id.

        * semantics.c (finish_expr_stmt): Call convert_to_void here.
        * decl.c (cplus_expand_expr_stmt): Not here.

        * rtti.c (build_dynamic_cast_1): Call non_lvalue.
        Initialize exprtype earlier.

        * parse.y (fn.def1): Check for defining types in return types.

        * decl.c (check_tag_decl): Notice extra fundamental types.
        Diagnose empty decls in classes, too.

        * decl.c (grokdeclarator): Don't override an anonymous name if no
        declarator was given.

        * cvt.c (convert_to_void): Call resolve_offset_ref.

        * typeck.c (build_x_function_call): Abort if we get an OFFSET_REF.

        * decl2.c (decl_namespace): Handle getting a type.

        * typeck.c (build_c_cast): Re-enable warning for cast between
        pointer and integer of different size.

From-SVN: r33066
This commit is contained in:
Jason Merrill 2000-04-11 00:38:39 +00:00 committed by Jason Merrill
parent a4ff8d98ba
commit 2bdb0643b3
10 changed files with 794 additions and 735 deletions

View File

@ -1,3 +1,30 @@
2000-04-10 Jason Merrill <jason@casey.cygnus.com>
* class.c (instantiate_type): Handle object-relative template-id.
* semantics.c (finish_expr_stmt): Call convert_to_void here.
* decl.c (cplus_expand_expr_stmt): Not here.
* rtti.c (build_dynamic_cast_1): Call non_lvalue.
Initialize exprtype earlier.
* parse.y (fn.def1): Check for defining types in return types.
* decl.c (check_tag_decl): Notice extra fundamental types.
Diagnose empty decls in classes, too.
* decl.c (grokdeclarator): Don't override an anonymous name if no
declarator was given.
* cvt.c (convert_to_void): Call resolve_offset_ref.
* typeck.c (build_x_function_call): Abort if we get an OFFSET_REF.
* decl2.c (decl_namespace): Handle getting a type.
* typeck.c (build_c_cast): Re-enable warning for cast between
pointer and integer of different size.
2000-04-10 Nathan Sidwell <nathan@codesourcery.com>
* inc/cxxabi.h (__pointer_type_info): Add restrict and

View File

@ -5442,6 +5442,9 @@ resolve_address_of_overloaded_function (target_type,
&& (TREE_CODE (TREE_TYPE (target_type))
== METHOD_TYPE)), 0);
if (TREE_CODE (overload) == COMPONENT_REF)
overload = TREE_OPERAND (overload, 1);
/* Check that the TARGET_TYPE is reasonable. */
if (TYPE_PTRFN_P (target_type))
/* This is OK. */
@ -5651,6 +5654,7 @@ instantiate_type (lhstype, rhs, flags)
{
int complain = (flags & 1);
int strict = (flags & 2) ? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT;
tree r;
if (TREE_CODE (lhstype) == UNKNOWN_TYPE)
{
@ -5711,8 +5715,9 @@ instantiate_type (lhstype, rhs, flags)
case COMPONENT_REF:
{
tree r = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags);
r = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), flags);
comp:
if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype)
&& complain && !flag_ms_extensions)
{
@ -5747,12 +5752,23 @@ instantiate_type (lhstype, rhs, flags)
/* Fall through. */
case TEMPLATE_ID_EXPR:
return
resolve_address_of_overloaded_function (lhstype,
TREE_OPERAND (rhs, 0),
complain,
/*template_only=*/1,
TREE_OPERAND (rhs, 1));
{
tree fns = TREE_OPERAND (rhs, 0);
tree args = TREE_OPERAND (rhs, 1);
r =
resolve_address_of_overloaded_function (lhstype,
fns,
complain,
/*template_only=*/1,
args);
if (TREE_CODE (fns) == COMPONENT_REF)
{
rhs = fns;
goto comp;
}
return r;
}
case OVERLOAD:
return

View File

@ -928,7 +928,11 @@ convert_to_void (expr, implicit)
expr, type, implicit ? implicit : "void context");
break;
}
case OFFSET_REF:
expr = resolve_offset_ref (expr);
break;
default:;
}
{

View File

@ -6781,6 +6781,7 @@ check_tag_decl (declspecs)
tree declspecs;
{
int found_type = 0;
int saw_friend = 0;
tree ob_modifier = NULL_TREE;
register tree link;
register tree t = NULL_TREE;
@ -6789,7 +6790,10 @@ check_tag_decl (declspecs)
{
register tree value = TREE_VALUE (link);
if (TYPE_P (value))
if (TYPE_P (value)
|| (TREE_CODE (value) == IDENTIFIER_NODE
&& IDENTIFIER_GLOBAL_VALUE (value)
&& TYPE_P (IDENTIFIER_GLOBAL_VALUE (value))))
{
++found_type;
@ -6804,6 +6808,8 @@ check_tag_decl (declspecs)
if (current_class_type == NULL_TREE
|| current_scope () != current_class_type)
ob_modifier = value;
else
saw_friend = 1;
}
else if (value == ridpointers[(int) RID_STATIC]
|| value == ridpointers[(int) RID_EXTERN]
@ -6820,9 +6826,7 @@ check_tag_decl (declspecs)
if (found_type > 1)
error ("multiple types in one declaration");
/* Inside a class, we might be in a friend or access declaration.
Until we have a good way of detecting the latter, don't warn. */
if (t == NULL_TREE && ! current_class_type)
if (t == NULL_TREE && ! saw_friend)
pedwarn ("declaration does not declare anything");
/* Check for an anonymous union. We're careful
@ -10922,6 +10926,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
Nothing can refer to it, so nothing needs know about the name
change. */
if (type != error_mark_node
&& declarator
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))
@ -14586,9 +14591,6 @@ void
cplus_expand_expr_stmt (exp)
tree exp;
{
if (stmts_are_full_exprs_p)
exp = convert_to_void (exp, "statement");
#if 0
/* We should do this eventually, but right now this causes regex.o from
libg++ to miscompile, and tString to core dump. */

View File

@ -4472,6 +4472,8 @@ static tree
decl_namespace (decl)
tree decl;
{
if (TYPE_P (decl))
decl = TYPE_STUB_DECL (decl);
while (DECL_CONTEXT (decl))
{
decl = DECL_CONTEXT (decl);

File diff suppressed because it is too large Load Diff

View File

@ -776,7 +776,8 @@ constructor_declarator:
fn.def1:
typed_declspecs declarator
{ if (!begin_function_definition ($1.t, $2))
{ check_for_new_type ("return type", $1);
if (!begin_function_definition ($1.t, $2))
YYERROR1; }
| declmods notype_declarator
{ if (!begin_function_definition ($1.t, $2))

View File

@ -558,7 +558,7 @@ build_dynamic_cast_1 (type, expr)
tree type, expr;
{
enum tree_code tc = TREE_CODE (type);
tree exprtype;
tree exprtype = TREE_TYPE (expr);
tree dcast_fn;
tree old_expr = expr;
const char *errstr = NULL;
@ -589,10 +589,10 @@ build_dynamic_cast_1 (type, expr)
}
if (TREE_CODE (expr) == OFFSET_REF)
expr = resolve_offset_ref (expr);
exprtype = TREE_TYPE (expr);
assert (exprtype != NULL_TREE);
{
expr = resolve_offset_ref (expr);
exprtype = TREE_TYPE (expr);
}
if (tc == POINTER_TYPE)
expr = convert_from_reference (expr);
@ -676,7 +676,12 @@ build_dynamic_cast_1 (type, expr)
}
if (distance >= 0)
return build_vbase_path (PLUS_EXPR, type, expr, path, 0);
{
expr = build_vbase_path (PLUS_EXPR, type, expr, path, 0);
if (TREE_CODE (exprtype) == POINTER_TYPE)
expr = non_lvalue (expr);
return expr;
}
}
/* Otherwise *exprtype must be a polymorphic class (have a vtbl). */

View File

@ -141,6 +141,9 @@ finish_expr_stmt (expr)
|| TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
expr = default_conversion (expr);
if (stmts_are_full_exprs_p)
expr = convert_to_void (expr, "statement");
if (!processing_template_decl)
expr = break_out_cleanups (expr);

View File

@ -2669,6 +2669,8 @@ build_x_function_call (function, params, decl)
return build_method_call (decl, function, params,
NULL_TREE, LOOKUP_NORMAL);
}
else if (TREE_CODE (function) == OFFSET_REF)
my_friendly_abort (20000406);
else if (TREE_CODE (function) == COMPONENT_REF
&& type == unknown_type_node)
{
@ -5473,9 +5475,6 @@ build_c_cast (type, expr)
cp_warning ("cast from `%T' to `%T' discards qualifiers from pointer target type",
otype, type);
#if 0
/* We should see about re-enabling these, they seem useful to
me. */
if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE
&& TYPE_PRECISION (type) != TYPE_PRECISION (otype))
@ -5488,7 +5487,6 @@ build_c_cast (type, expr)
provided the 0 was explicit--not cast or made by folding. */
&& !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
warning ("cast to pointer from integer of different size");
#endif
if (TREE_CODE (type) == REFERENCE_TYPE)
value = (convert_from_reference