Commit 2bdb0643 by Jason Merrill Committed by Jason Merrill

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
parent a4ff8d98
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> 2000-04-10 Nathan Sidwell <nathan@codesourcery.com>
* inc/cxxabi.h (__pointer_type_info): Add restrict and * inc/cxxabi.h (__pointer_type_info): Add restrict and
......
...@@ -5442,6 +5442,9 @@ resolve_address_of_overloaded_function (target_type, ...@@ -5442,6 +5442,9 @@ resolve_address_of_overloaded_function (target_type,
&& (TREE_CODE (TREE_TYPE (target_type)) && (TREE_CODE (TREE_TYPE (target_type))
== METHOD_TYPE)), 0); == METHOD_TYPE)), 0);
if (TREE_CODE (overload) == COMPONENT_REF)
overload = TREE_OPERAND (overload, 1);
/* Check that the TARGET_TYPE is reasonable. */ /* Check that the TARGET_TYPE is reasonable. */
if (TYPE_PTRFN_P (target_type)) if (TYPE_PTRFN_P (target_type))
/* This is OK. */ /* This is OK. */
...@@ -5651,6 +5654,7 @@ instantiate_type (lhstype, rhs, flags) ...@@ -5651,6 +5654,7 @@ instantiate_type (lhstype, rhs, flags)
{ {
int complain = (flags & 1); int complain = (flags & 1);
int strict = (flags & 2) ? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT; int strict = (flags & 2) ? COMPARE_NO_ATTRIBUTES : COMPARE_STRICT;
tree r;
if (TREE_CODE (lhstype) == UNKNOWN_TYPE) if (TREE_CODE (lhstype) == UNKNOWN_TYPE)
{ {
...@@ -5711,8 +5715,9 @@ instantiate_type (lhstype, rhs, flags) ...@@ -5711,8 +5715,9 @@ instantiate_type (lhstype, rhs, flags)
case COMPONENT_REF: 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) if (r != error_mark_node && TYPE_PTRMEMFUNC_P (lhstype)
&& complain && !flag_ms_extensions) && complain && !flag_ms_extensions)
{ {
...@@ -5747,12 +5752,23 @@ instantiate_type (lhstype, rhs, flags) ...@@ -5747,12 +5752,23 @@ instantiate_type (lhstype, rhs, flags)
/* Fall through. */ /* Fall through. */
case TEMPLATE_ID_EXPR: case TEMPLATE_ID_EXPR:
return {
tree fns = TREE_OPERAND (rhs, 0);
tree args = TREE_OPERAND (rhs, 1);
r =
resolve_address_of_overloaded_function (lhstype, resolve_address_of_overloaded_function (lhstype,
TREE_OPERAND (rhs, 0), fns,
complain, complain,
/*template_only=*/1, /*template_only=*/1,
TREE_OPERAND (rhs, 1)); args);
if (TREE_CODE (fns) == COMPONENT_REF)
{
rhs = fns;
goto comp;
}
return r;
}
case OVERLOAD: case OVERLOAD:
return return
......
...@@ -929,6 +929,10 @@ convert_to_void (expr, implicit) ...@@ -929,6 +929,10 @@ convert_to_void (expr, implicit)
break; break;
} }
case OFFSET_REF:
expr = resolve_offset_ref (expr);
break;
default:; default:;
} }
{ {
......
...@@ -6781,6 +6781,7 @@ check_tag_decl (declspecs) ...@@ -6781,6 +6781,7 @@ check_tag_decl (declspecs)
tree declspecs; tree declspecs;
{ {
int found_type = 0; int found_type = 0;
int saw_friend = 0;
tree ob_modifier = NULL_TREE; tree ob_modifier = NULL_TREE;
register tree link; register tree link;
register tree t = NULL_TREE; register tree t = NULL_TREE;
...@@ -6789,7 +6790,10 @@ check_tag_decl (declspecs) ...@@ -6789,7 +6790,10 @@ check_tag_decl (declspecs)
{ {
register tree value = TREE_VALUE (link); 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; ++found_type;
...@@ -6804,6 +6808,8 @@ check_tag_decl (declspecs) ...@@ -6804,6 +6808,8 @@ check_tag_decl (declspecs)
if (current_class_type == NULL_TREE if (current_class_type == NULL_TREE
|| current_scope () != current_class_type) || current_scope () != current_class_type)
ob_modifier = value; ob_modifier = value;
else
saw_friend = 1;
} }
else if (value == ridpointers[(int) RID_STATIC] else if (value == ridpointers[(int) RID_STATIC]
|| value == ridpointers[(int) RID_EXTERN] || value == ridpointers[(int) RID_EXTERN]
...@@ -6820,9 +6826,7 @@ check_tag_decl (declspecs) ...@@ -6820,9 +6826,7 @@ check_tag_decl (declspecs)
if (found_type > 1) if (found_type > 1)
error ("multiple types in one declaration"); error ("multiple types in one declaration");
/* Inside a class, we might be in a friend or access declaration. if (t == NULL_TREE && ! saw_friend)
Until we have a good way of detecting the latter, don't warn. */
if (t == NULL_TREE && ! current_class_type)
pedwarn ("declaration does not declare anything"); pedwarn ("declaration does not declare anything");
/* Check for an anonymous union. We're careful /* Check for an anonymous union. We're careful
...@@ -10922,6 +10926,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -10922,6 +10926,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
Nothing can refer to it, so nothing needs know about the name Nothing can refer to it, so nothing needs know about the name
change. */ change. */
if (type != error_mark_node if (type != error_mark_node
&& declarator
&& TYPE_NAME (type) && TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)) && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))
...@@ -14586,9 +14591,6 @@ void ...@@ -14586,9 +14591,6 @@ void
cplus_expand_expr_stmt (exp) cplus_expand_expr_stmt (exp)
tree exp; tree exp;
{ {
if (stmts_are_full_exprs_p)
exp = convert_to_void (exp, "statement");
#if 0 #if 0
/* We should do this eventually, but right now this causes regex.o from /* We should do this eventually, but right now this causes regex.o from
libg++ to miscompile, and tString to core dump. */ libg++ to miscompile, and tString to core dump. */
......
...@@ -4472,6 +4472,8 @@ static tree ...@@ -4472,6 +4472,8 @@ static tree
decl_namespace (decl) decl_namespace (decl)
tree decl; tree decl;
{ {
if (TYPE_P (decl))
decl = TYPE_STUB_DECL (decl);
while (DECL_CONTEXT (decl)) while (DECL_CONTEXT (decl))
{ {
decl = DECL_CONTEXT (decl); decl = DECL_CONTEXT (decl);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -776,7 +776,8 @@ constructor_declarator: ...@@ -776,7 +776,8 @@ constructor_declarator:
fn.def1: fn.def1:
typed_declspecs declarator 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; } YYERROR1; }
| declmods notype_declarator | declmods notype_declarator
{ if (!begin_function_definition ($1.t, $2)) { if (!begin_function_definition ($1.t, $2))
......
...@@ -558,7 +558,7 @@ build_dynamic_cast_1 (type, expr) ...@@ -558,7 +558,7 @@ build_dynamic_cast_1 (type, expr)
tree type, expr; tree type, expr;
{ {
enum tree_code tc = TREE_CODE (type); enum tree_code tc = TREE_CODE (type);
tree exprtype; tree exprtype = TREE_TYPE (expr);
tree dcast_fn; tree dcast_fn;
tree old_expr = expr; tree old_expr = expr;
const char *errstr = NULL; const char *errstr = NULL;
...@@ -589,10 +589,10 @@ build_dynamic_cast_1 (type, expr) ...@@ -589,10 +589,10 @@ build_dynamic_cast_1 (type, expr)
} }
if (TREE_CODE (expr) == OFFSET_REF) if (TREE_CODE (expr) == OFFSET_REF)
{
expr = resolve_offset_ref (expr); expr = resolve_offset_ref (expr);
exprtype = TREE_TYPE (expr); exprtype = TREE_TYPE (expr);
assert (exprtype != NULL_TREE); }
if (tc == POINTER_TYPE) if (tc == POINTER_TYPE)
expr = convert_from_reference (expr); expr = convert_from_reference (expr);
...@@ -676,7 +676,12 @@ build_dynamic_cast_1 (type, expr) ...@@ -676,7 +676,12 @@ build_dynamic_cast_1 (type, expr)
} }
if (distance >= 0) 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). */ /* Otherwise *exprtype must be a polymorphic class (have a vtbl). */
......
...@@ -141,6 +141,9 @@ finish_expr_stmt (expr) ...@@ -141,6 +141,9 @@ finish_expr_stmt (expr)
|| TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)) || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
expr = default_conversion (expr); expr = default_conversion (expr);
if (stmts_are_full_exprs_p)
expr = convert_to_void (expr, "statement");
if (!processing_template_decl) if (!processing_template_decl)
expr = break_out_cleanups (expr); expr = break_out_cleanups (expr);
......
...@@ -2669,6 +2669,8 @@ build_x_function_call (function, params, decl) ...@@ -2669,6 +2669,8 @@ build_x_function_call (function, params, decl)
return build_method_call (decl, function, params, return build_method_call (decl, function, params,
NULL_TREE, LOOKUP_NORMAL); NULL_TREE, LOOKUP_NORMAL);
} }
else if (TREE_CODE (function) == OFFSET_REF)
my_friendly_abort (20000406);
else if (TREE_CODE (function) == COMPONENT_REF else if (TREE_CODE (function) == COMPONENT_REF
&& type == unknown_type_node) && type == unknown_type_node)
{ {
...@@ -5473,9 +5475,6 @@ build_c_cast (type, expr) ...@@ -5473,9 +5475,6 @@ build_c_cast (type, expr)
cp_warning ("cast from `%T' to `%T' discards qualifiers from pointer target type", cp_warning ("cast from `%T' to `%T' discards qualifiers from pointer target type",
otype, type); otype, type);
#if 0
/* We should see about re-enabling these, they seem useful to
me. */
if (TREE_CODE (type) == INTEGER_TYPE if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE && TREE_CODE (otype) == POINTER_TYPE
&& TYPE_PRECISION (type) != TYPE_PRECISION (otype)) && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
...@@ -5488,7 +5487,6 @@ build_c_cast (type, expr) ...@@ -5488,7 +5487,6 @@ build_c_cast (type, expr)
provided the 0 was explicit--not cast or made by folding. */ provided the 0 was explicit--not cast or made by folding. */
&& !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value))) && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
warning ("cast to pointer from integer of different size"); warning ("cast to pointer from integer of different size");
#endif
if (TREE_CODE (type) == REFERENCE_TYPE) if (TREE_CODE (type) == REFERENCE_TYPE)
value = (convert_from_reference value = (convert_from_reference
......
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