class.c (layout_class_type): Do not issue C++ ABI warnings for ObjC structs.

* class.c (layout_class_type): Do not issue C++ ABI warnings
        for ObjC structs.
        * decl.c (objc_mark_locals_volatile): Streamline by calling
        objc_volatilize_decl().
        * parser.c (cp_parser_objc_message_expression): Allow simple
        type specifiers (instead of merely type names) as message
        receivers.
        * pt.c (template_args_equal): Do not call objc_comptypes().
        * typeck.c (composite_pointer_type): If both pointers are
        ObjC-esque, arbitrarily choose the first; do not call
        objc_comptypes().
        (comptypes): Do not call objc_comptypes().
        (convert_for_assignment): Call objc_compare_types().
        (comp_ptr_ttypes_real): Call objc_type_quals_match() before
        concluding that types do not match.

From-SVN: r100125
This commit is contained in:
Ziemowit Laski 2005-05-24 22:22:33 +00:00 committed by Mike Stump
parent d11dd68408
commit 660845bf3a
6 changed files with 72 additions and 66 deletions

View File

@ -1,3 +1,21 @@
2005-05-24 Ziemowit Laski <zlaski@apple.com>
* class.c (layout_class_type): Do not issue C++ ABI warnings
for ObjC structs.
* decl.c (objc_mark_locals_volatile): Streamline by calling
objc_volatilize_decl().
* parser.c (cp_parser_objc_message_expression): Allow simple
type specifiers (instead of merely type names) as message
receivers.
* pt.c (template_args_equal): Do not call objc_comptypes().
* typeck.c (composite_pointer_type): If both pointers are
ObjC-esque, arbitrarily choose the first; do not call
objc_comptypes().
(comptypes): Do not call objc_comptypes().
(convert_for_assignment): Call objc_compare_types().
(comp_ptr_ttypes_real): Call objc_type_quals_match() before
concluding that types do not match.
2005-05-24 Andrew Pinski <pinskia@physics.uc.edu>
PR C++/21645

View File

@ -4681,6 +4681,11 @@ layout_class_type (tree t, tree *virtuals_p)
comply with the ABI. */
if (warn_abi
&& DECL_C_BIT_FIELD (field)
/* The TREE_NO_WARNING flag gets set by Objective-C when
laying out an Objective-C class. The ObjC ABI differs
from the C++ ABI, and so we do not want a warning
here. */
&& !TREE_NO_WARNING (field)
&& !last_field_was_bitfield
&& !integer_zerop (size_binop (TRUNC_MOD_EXPR,
DECL_FIELD_BIT_OFFSET (field),

View File

@ -425,22 +425,7 @@ objc_mark_locals_volatile (void *enclosing_blk)
tree decl;
for (decl = scope->names; decl; decl = TREE_CHAIN (decl))
{
/* Do not mess with variables that are 'static' or (already)
'volatile'. */
if (!TREE_THIS_VOLATILE (decl) && !TREE_STATIC (decl)
&& (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL))
{
TREE_TYPE (decl)
= build_qualified_type (TREE_TYPE (decl),
(TYPE_QUALS (TREE_TYPE (decl))
| TYPE_QUAL_VOLATILE));
TREE_THIS_VOLATILE (decl) = 1;
TREE_SIDE_EFFECTS (decl) = 1;
DECL_REGISTER (decl) = 0;
}
}
objc_volatilize_decl (decl);
/* Do not climb up past the current function. */
if (scope->kind == sk_function_parms)

View File

@ -16258,8 +16258,8 @@ cp_parser_objc_message_expression (cp_parser* parser)
/* Parse an objc-message-receiver.
objc-message-receiver:
type-name
expression
simple-type-specifier
Returns a representation of the type or expression. */
@ -16267,7 +16267,6 @@ static tree
cp_parser_objc_message_receiver (cp_parser* parser)
{
tree rcv;
bool class_scope_p, template_p;
/* An Objective-C message receiver may be either (1) a type
or (2) an expression. */
@ -16277,24 +16276,9 @@ cp_parser_objc_message_receiver (cp_parser* parser)
if (cp_parser_parse_definitely (parser))
return rcv;
/* Look for the optional `::' operator. */
cp_parser_global_scope_opt (parser, false);
/* Look for the nested-name-specifier. */
cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/true,
/*check_dependency_p=*/true,
/*type_p=*/true,
/*is_declaration=*/true);
class_scope_p = (parser->scope && TYPE_P (parser->scope));
template_p = class_scope_p && cp_parser_optional_template_keyword (parser);
/* Finally, look for the class-name. */
rcv = cp_parser_class_name (parser,
class_scope_p,
template_p,
/*type_p=*/true,
/*check_dependency_p=*/true,
/*class_head_p=*/false,
/*is_declaration=*/true);
rcv = cp_parser_simple_type_specifier (parser,
/*decl_specs=*/NULL,
CP_PARSER_FLAGS_NONE);
return objc_get_class_reference (rcv);
}

View File

@ -4026,24 +4026,7 @@ template_args_equal (tree ot, tree nt)
/* For member templates */
return TREE_CODE (ot) == TREE_VEC && comp_template_args (ot, nt);
else if (TYPE_P (nt))
{
int c1, c2;
if (!TYPE_P (ot))
return 0;
/* We must handle ObjC types specially because they may differ
only in protocol qualifications (e.g., 'NSObject *' vs.
'NSObject <Foo> *') that must be taken into account here.
See also cp/typeck.c:build_c_cast(), where a similar problem
arises. We must call objc_comptypes() twice, since its
comparisons are _not_ symmetric. */
if ((c1 = objc_comptypes (ot, nt, 0)) >= 0
&& (c2 = objc_comptypes (nt, ot, 0)) >= 0)
return (c1 && c2);
return same_type_p (ot, nt);
}
return TYPE_P (ot) && same_type_p (ot, nt);
else if (TREE_CODE (ot) == TREE_VEC || TYPE_P (ot))
return 0;
else

View File

@ -503,6 +503,13 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
return build_type_attribute_variant (result_type, attributes);
}
if (c_dialect_objc () && TREE_CODE (t1) == POINTER_TYPE
&& TREE_CODE (t2) == POINTER_TYPE)
{
if (objc_compare_types (t1, t2, -3, NULL_TREE))
return t1;
}
/* [expr.eq] permits the application of a pointer conversion to
bring the pointers to a common type. */
if (TREE_CODE (t1) == POINTER_TYPE && TREE_CODE (t2) == POINTER_TYPE
@ -514,12 +521,10 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
class1 = TREE_TYPE (t1);
class2 = TREE_TYPE (t2);
if (DERIVED_FROM_P (class1, class2) ||
(c_dialect_objc () && objc_comptypes (class1, class2, 0) == 1))
if (DERIVED_FROM_P (class1, class2))
t2 = (build_pointer_type
(cp_build_qualified_type (class1, TYPE_QUALS (class2))));
else if (DERIVED_FROM_P (class2, class1) ||
(c_dialect_objc () && objc_comptypes (class2, class1, 0) == 1))
else if (DERIVED_FROM_P (class2, class1))
t1 = (build_pointer_type
(cp_build_qualified_type (class2, TYPE_QUALS (class1))));
else
@ -1000,11 +1005,6 @@ comptypes (tree t1, tree t2, int strict)
else if ((strict & COMPARE_DERIVED) && DERIVED_FROM_P (t2, t1))
break;
/* We may be dealing with Objective-C instances. */
if (TREE_CODE (t1) == RECORD_TYPE
&& objc_comptypes (t1, t2, 0) > 0)
break;
return false;
case OFFSET_TYPE:
@ -5832,7 +5832,33 @@ convert_for_assignment (tree type, tree rhs,
/* Simplify the RHS if possible. */
if (TREE_CODE (rhs) == CONST_DECL)
rhs = DECL_INITIAL (rhs);
if (c_dialect_objc ())
{
int parmno;
tree rname = fndecl;
if (!strcmp (errtype, "assignment"))
parmno = -1;
else if (!strcmp (errtype, "initialization"))
parmno = -2;
else
{
tree selector = objc_message_selector ();
parmno = parmnum;
if (selector && parmno > 1)
{
rname = selector;
parmno -= 1;
}
}
if (objc_compare_types (type, rhstype, parmno, rname))
return convert (type, rhs);
}
/* [expr.ass]
The expression is implicitly converted (clause _conv_) to the
@ -6257,10 +6283,15 @@ comp_ptr_ttypes_real (tree to, tree from, int constp)
so the usual checks are not appropriate. */
if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
{
if (!at_least_as_qualified_p (to, from))
/* In Objective-C++, some types may have been 'volatilized' by
the compiler for EH; when comparing them here, the volatile
qualification must be ignored. */
bool objc_quals_match = objc_type_quals_match (to, from);
if (!at_least_as_qualified_p (to, from) && !objc_quals_match)
return 0;
if (!at_least_as_qualified_p (from, to))
if (!at_least_as_qualified_p (from, to) && !objc_quals_match)
{
if (constp == 0)
return 0;