In gcc/: 2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>

In gcc/:
2010-09-27  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.  Removed small
        change in build_conditional_expr that had been added when fixing
        PR objc/27377 and which did the same check in a less complete way.

        2005-12-15  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4229905
        * c-typeck.c (build_conditional_expr): Call objc_have_common_type when
        looking for objective-c common pointer types.

        2005-06-22  Ziemowit Laski  <zlaski@apple.com>

        Radar 4154928
        * c-typeck.c (build_conditional_expr): For two ObjC pointer types,
        use their ObjC common type.

In gcc/c-family:
2010-09-27  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.

        2005-12-15  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4229905
        * c-common.h (objc_have_common_type): New declaration.
        * stub-objc.c (objc_have_common_type): New stub.

        2005-06-22  Ziemowit Laski  <zlaski@apple.com>

        Radar 4154928
        * c-common.h (objc_common_type): New prototype.
        * stub-objc.c (objc_common_type): New stub.

In gcc/objc/:
2010-09-27  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.

        2005-12-15  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4229905
        * objc-act.c (objc_have_common_types): New function.

        2005-06-22  Ziemowit Laski  <zlaski@apple.com>

        Radar 4154928
        * objc-act.c (objc_common_type): New function.

In gcc/cp/:
2010-09-27  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from apple/trunk branch on FSF servers:

        2005-12-15  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4229905
        * typeck.c (composite_pointer_type): Call objc_have_common_type
        when comparing two objective-c pointer types.

        2005-06-22  Ziemowit Laski  <zlaski@apple.com>

        Radar 4154928
        * call.c (standard_conversion): Allow for a pointer conversion
        between any two ObjC pointer types.
        * typeck.c (composite_pointer_type): Determine common type
        for two ObjC pointer types.

In gcc/testsuite/:
2010-09-27  Nicola Pero  <nicola.pero@meta-innovation.com>

        Merge from 'apple/trunk' branch on FSF servers.  Renamed
        const-str-12.m to constr-str-12b.m to avoid conflicts.

        2005-12-15  Fariborz Jahanian <fjahanian@apple.com>

        Radar 4229905
        * obj-c++.dg/warn5.mm: New

        2005-06-22  Ziemowit Laski  <zlaski@apple.com>

        Radar 4154928
        * obj-c++.dg/const-str-12.mm: New.
        * objc.dg/const-str-12.m: New.

From-SVN: r164655
This commit is contained in:
Nicola Pero 2010-09-27 18:04:09 +00:00 committed by Nicola Pero
parent aa2b7414b0
commit b581b85b2e
14 changed files with 237 additions and 8 deletions

View file

@ -1,3 +1,21 @@
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers. Removed small
change in build_conditional_expr that had been added when fixing
PR objc/27377 and which did the same check in a less complete way.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* c-typeck.c (build_conditional_expr): Call objc_have_common_type when
looking for objective-c common pointer types.
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* c-typeck.c (build_conditional_expr): For two ObjC pointer types,
use their ObjC common type.
2010-09-27 Richard Guenther <rguenther@suse.de>
* dbxout.c (dbxout_symbol): Use DECL_FILE_SCOPE_P.

View file

@ -1,3 +1,19 @@
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* c-common.h (objc_have_common_type): New declaration.
* stub-objc.c (objc_have_common_type): New stub.
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* c-common.h (objc_common_type): New prototype.
* stub-objc.c (objc_common_type): New stub.
2010-09-24 Jan Hubicka <jh@suse.cz>
* c-common.c (handle_leaf_attribute): New function.

View file

@ -941,7 +941,9 @@ extern tree objc_is_class_name (tree);
extern tree objc_is_object_ptr (tree);
extern void objc_check_decl (tree);
extern int objc_is_reserved_word (tree);
extern tree objc_common_type (tree, tree);
extern bool objc_compare_types (tree, tree, int, tree);
extern bool objc_have_common_type (tree, tree, int, tree);
extern void objc_volatilize_decl (tree);
extern bool objc_type_quals_match (tree, tree);
extern tree objc_rewrite_function_call (tree, tree);

View file

@ -62,6 +62,12 @@ objc_is_reserved_word (tree ARG_UNUSED (ident))
return 0;
}
tree
objc_common_type (tree ARG_UNUSED (type1), tree ARG_UNUSED (type2))
{
return 0;
}
bool
objc_compare_types (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
int ARG_UNUSED (argno), tree ARG_UNUSED (callee))
@ -69,6 +75,13 @@ objc_compare_types (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
return false;
}
bool
objc_have_common_type (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
int ARG_UNUSED (argno), tree ARG_UNUSED (callee))
{
return false;
}
void
objc_volatilize_decl (tree ARG_UNUSED (decl))
{

View file

@ -4051,7 +4051,6 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
bool int_const, op1_int_operands, op2_int_operands, int_operands;
bool ifexp_int_operands;
tree ret;
bool objc_ok;
op1_int_operands = EXPR_INT_CONST_OPERANDS (orig_op1);
if (op1_int_operands)
@ -4088,8 +4087,6 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
return error_mark_node;
}
objc_ok = objc_compare_types (type1, type2, -3, NULL_TREE);
if ((TREE_CODE (op1) == EXCESS_PRECISION_EXPR
|| TREE_CODE (op2) == EXCESS_PRECISION_EXPR)
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
@ -4255,13 +4252,15 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
result_type = build_pointer_type (qualify_type (TREE_TYPE (type2),
TREE_TYPE (type1)));
}
/* Objective-C pointer comparisons are a bit more lenient. */
else if (objc_have_common_type (type1, type2, -3, NULL_TREE))
result_type = objc_common_type (type1, type2);
else
{
int qual = ENCODE_QUAL_ADDR_SPACE (as_common);
if (!objc_ok)
pedwarn (colon_loc, 0,
"pointer type mismatch in conditional expression");
pedwarn (colon_loc, 0,
"pointer type mismatch in conditional expression");
result_type = build_pointer_type
(build_qualified_type (void_type_node, qual));
}

View file

@ -1,3 +1,21 @@
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from apple/trunk branch on FSF servers:
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* typeck.c (composite_pointer_type): Call objc_have_common_type
when comparing two objective-c pointer types.
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* call.c (standard_conversion): Allow for a pointer conversion
between any two ObjC pointer types.
* typeck.c (composite_pointer_type): Determine common type
for two ObjC pointer types.
2010-09-24 Jan Hubicka <jh@suse.cz>
* decl.c (finish_function): Use decl_replaceable_p

View file

@ -900,6 +900,11 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
else if (expr && string_conv_p (to, expr, 0))
/* converting from string constant to char *. */
conv = build_conv (ck_qual, to, conv);
/* Allow conversions among compatible ObjC pointer types (base
conversions have been already handled above). */
else if (c_dialect_objc ()
&& objc_compare_types (to, from, -4, NULL_TREE))
conv = build_conv (ck_ptr, to, conv);
else if (ptr_reasonably_similar (to_pointee, from_pointee))
{
conv = build_conv (ck_ptr, to, conv);

View file

@ -632,8 +632,8 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
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;
if (objc_have_common_type (t1, t2, -3, NULL_TREE))
return objc_common_type (t1, t2);
}
/* [expr.eq] permits the application of a pointer conversion to

View file

@ -1,3 +1,17 @@
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* objc-act.c (objc_have_common_types): New function.
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* objc-act.c (objc_common_type): New function.
2010-09-27 Richard Guenther <rguenther@suse.de>
* objc-act.c (objc_get_class_reference): Use CP_TYPE_CONTEXT.

View file

@ -1100,6 +1100,35 @@ objc_compare_protocols (tree lcls, tree ltyp, tree rcls, tree rtyp, bool warn)
return have_lproto || (rcls != NULL_TREE);
}
/* Given two types TYPE1 and TYPE2, return their least common ancestor.
Both TYPE1 and TYPE2 must be pointers, and already determined to be
compatible by objc_compare_types() below. */
tree
objc_common_type (tree type1, tree type2)
{
tree inner1 = TREE_TYPE (type1), inner2 = TREE_TYPE (type2);
while (POINTER_TYPE_P (inner1))
{
inner1 = TREE_TYPE (inner1);
inner2 = TREE_TYPE (inner2);
}
/* If one type is derived from another, return the base type. */
if (DERIVED_FROM_P (inner1, inner2))
return type1;
else if (DERIVED_FROM_P (inner2, inner1))
return type2;
/* If both types are 'Class', return 'Class'. */
if (objc_is_class_id (inner1) && objc_is_class_id (inner2))
return objc_class_type;
/* Otherwise, return 'id'. */
return objc_object_type;
}
/* Determine if it is permissible to assign (if ARGNO is greater than -3)
an instance of RTYP to an instance of LTYP or to compare the two
(if ARGNO is equal to -3), per ObjC type system rules. Before
@ -1273,6 +1302,28 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee)
return true;
}
/* This routine is similar to objc_compare_types except that function-pointers are
excluded. This is because, caller assumes that common types are of (id, Object*)
variety and calls objc_common_type to obtain a common type. There is no commonolty
between two function-pointers in this regard. */
bool
objc_have_common_type (tree ltyp, tree rtyp, int argno, tree callee)
{
if (objc_compare_types (ltyp, rtyp, argno, callee))
{
/* exclude function-pointer types. */
do
{
ltyp = TREE_TYPE (ltyp); /* Remove indirections. */
rtyp = TREE_TYPE (rtyp);
}
while (POINTER_TYPE_P (ltyp) && POINTER_TYPE_P (rtyp));
return !(TREE_CODE (ltyp) == FUNCTION_TYPE && TREE_CODE (rtyp) == FUNCTION_TYPE);
}
return false;
}
/* Check if LTYP and RTYP have the same type qualifiers. If either type
lives in the volatilized hash table, ignore the 'volatile' bit when
making the comparison. */

View file

@ -1,3 +1,19 @@
2010-09-27 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers. Renamed
const-str-12.m to constr-str-12b.m to avoid conflicts.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* obj-c++.dg/warn5.mm: New
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* obj-c++.dg/const-str-12.mm: New.
* objc.dg/const-str-12.m: New.
2010-09-27 Tobias Burnus <burnus@net-b.de>
PR fortran/40569

View file

@ -0,0 +1,26 @@
/* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */
#include "../objc-obj-c++-shared/Object1.h"
@interface Foo: Object {
char *cString;
unsigned int len;
}
+ (id)description;
@end
@interface Bar: Object
+ (Foo *) getString: (int) which;
@end
struct objc_class _FooClassReference;
@implementation Bar
+ (Foo *) getString: (int) which {
return which? [Foo description]: @"Hello";
}
@end

View file

@ -0,0 +1,25 @@
/* Check to make sure that a c++ program compiled in objective-c++ mode
has no trace of meta-data specific diagnosis coming out of compiling it.
This is replicate of warn5.C.
*/
// { dg-do assemble }
// { dg-options "-Wpointer-arith" }
double X(const double x) { return x; }
double Y() { return 1.0; }
double Z() { return 2.0; }
struct A {
void bar() { }
void foo() { }
};
typedef void (A::*pmf)();
static int mememe = &A::foo - &A::bar; // { dg-warning "" }
pmf b = &A::foo-1; // { dg-warning "" }
int main() {
double y;
y=X(Y-Z); // { dg-warning "" }
}

View file

@ -0,0 +1,26 @@
/* Test if ObjC types play nice in conditional expressions. */
/* Author: Ziemowit Laski */
/* { dg-options "-fconstant-string-class=Foo" } */
/* { dg-do compile } */
#include "../objc-obj-c++-shared/Object1.h"
@interface Foo: Object {
char *cString;
unsigned int len;
}
+ (id)description;
@end
@interface Bar: Object
+ (Foo *) getString: (int) which;
@end
struct objc_class _FooClassReference;
@implementation Bar
+ (Foo *) getString: (int) which {
return which? [Foo description]: @"Hello";
}
@end