diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-09-28 10:20:11 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-09-28 10:20:11 +0000 |
commit | 4c1165050677dbdc26d844fadf2b3b57da1266bf (patch) | |
tree | a7ac33700a77cb5832f2f995916ce6c5f07d2ee0 /gcc | |
parent | 06e67e167d96b750e484be95a0538a8aea488436 (diff) | |
download | gcc-4c1165050677dbdc26d844fadf2b3b57da1266bf.zip gcc-4c1165050677dbdc26d844fadf2b3b57da1266bf.tar.gz gcc-4c1165050677dbdc26d844fadf2b3b57da1266bf.tar.bz2 |
In gcc/objc/: 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/:
2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-07-18 Ziemowit Laski <zlaski@apple.com>
Radar 4175534
* objc-act.c (objc_compare_types): A new silent comparison
mode (-4), differing from regular comparison (-3) in that
'false' is returned instead of issuing warnings.
In gcc/testsuite/:
2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers.
2005-07-18 Ziemowit Laski <zlaski@apple.com>
Radar 4175534
* obj-c++.dg/method-22.mm: New.
From-SVN: r164681
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/objc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/objc/objc-act.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/obj-c++.dg/method-22.mm | 42 |
4 files changed, 75 insertions, 4 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index e274a86..b174bcf 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,5 +1,16 @@ 2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com> + Merge from 'apple/trunk' branch on FSF servers. + + 2005-07-18 Ziemowit Laski <zlaski@apple.com> + + Radar 4175534 + * objc-act.c (objc_compare_types): A new silent comparison + mode (-4), differing from regular comparison (-3) in that + 'false' is returned instead of issuing warnings. + +2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com> + * objc-act.c (encode_type): Do not add 'r' with the next runtime. (encode_aggregate_within): Reorganized code to be more readable. (encode_aggregate_fields): Updated second argument to be 'bool' diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 39f0b5c..ecf3782 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1143,7 +1143,9 @@ objc_common_type (tree type1, tree type2) 0 Return value; -1 Assignment; -2 Initialization; - -3 Comparison (LTYP and RTYP may match in either direction). */ + -3 Comparison (LTYP and RTYP may match in either direction); + -4 Silent comparison (for C++ overload resolution). + */ bool objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee) @@ -1198,8 +1200,9 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee) && !TYPE_HAS_OBJC_INFO (rtyp)) return false; - /* Past this point, we are committed to returning 'true' to the caller. - However, we can still warn about type and/or protocol mismatches. */ + /* Past this point, we are committed to returning 'true' to the caller + (unless performing a silent comparison; see below). However, we can + still warn about type and/or protocol mismatches. */ if (TYPE_HAS_OBJC_INFO (ltyp)) { @@ -1253,7 +1256,7 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee) if (!pointers_compatible) pointers_compatible = DERIVED_FROM_P (ltyp, rtyp); - if (!pointers_compatible && argno == -3) + if (!pointers_compatible && argno <= -3) pointers_compatible = DERIVED_FROM_P (rtyp, ltyp); } @@ -1271,11 +1274,17 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee) if (!pointers_compatible) { + /* The two pointers are not exactly compatible. Issue a warning, unless + we are performing a silent comparison, in which case return 'false' + instead. */ /* NB: For the time being, we shall make our warnings look like their C counterparts. In the future, we may wish to make them more ObjC-specific. */ switch (argno) { + case -4: + return false; + case -3: warning (0, "comparison of distinct Objective-C types lacks a cast"); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f56e709..c7bb80b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2010-09-28 Nicola Pero <nicola.pero@meta-innovation.com> + + Merge from 'apple/trunk' branch on FSF servers. + + 2005-07-18 Ziemowit Laski <zlaski@apple.com> + + Radar 4175534 + * obj-c++.dg/method-22.mm: New. + 2010-09-27 Jason Merrill <jason@redhat.com> * g++.dg/cpp0x/rv-lvalue-req.C: New. diff --git a/gcc/testsuite/obj-c++.dg/method-22.mm b/gcc/testsuite/obj-c++.dg/method-22.mm new file mode 100644 index 0000000..583607b --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/method-22.mm @@ -0,0 +1,42 @@ +/* Ensure that overload resolution does not produce warnings as + side-effects. */ +/* { dg-do run } */ + +#include "../objc-obj-c++-shared/Object1.h" +#include <stdlib.h> + +#define CHECK_IF(E) if(!(E)) abort () + +@interface MyCursor: Object ++ (MyCursor *)crosshairCursor; +@end + +@class MyImage; + +class A { +public: + A(); + + int foo(MyImage *); + int foo(MyCursor *); +}; + +A::A() {} +int A::foo(MyCursor * c) { return 17; } +int A::foo(MyImage * i) { return 29; } + +@implementation MyCursor ++ (MyCursor *)crosshairCursor { + return self; +} +@end + +int main(void) { + A a; + + int r = a.foo([MyCursor crosshairCursor]); + + CHECK_IF (r == 17); + return 0; +} + |