diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/obj-c++.dg/comp-types-5.mm | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/comp-types-5.mm')
-rw-r--r-- | gcc/testsuite/obj-c++.dg/comp-types-5.mm | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/comp-types-5.mm b/gcc/testsuite/obj-c++.dg/comp-types-5.mm new file mode 100644 index 000000000..99f6772bd --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/comp-types-5.mm @@ -0,0 +1,74 @@ +/* Test errors for assignments and comparisons between ObjC and C++ types. */ +/* Author: Nicola Pero <nicola@brainstorm.co.uk>. */ +/* { dg-do compile } */ + +#include <objc/objc.h> + +/* The NeXT runtime headers do not define NULL. */ +#ifndef NULL +#define NULL ((void *)0) +#endif + +@protocol MyProtocol +- (void) method; +@end + +@interface MyClass +@end + +int main() +{ + id obj = nil; + id <MyProtocol> obj_p = nil; + MyClass *obj_c = nil; + Class obj_C = Nil; + + int i = 0; + int *j = (int *)NULL; + + /* These should all generate warnings. */ + + obj = i; /* { dg-error "invalid conversion" } */ + obj = j; /* { dg-error "cannot convert" } */ + + obj_p = i; /* { dg-error "invalid conversion" } */ + obj_p = j; /* { dg-error "cannot convert" } */ + + obj_c = i; /* { dg-error "invalid conversion" } */ + obj_c = j; /* { dg-error "cannot convert" } */ + + obj_C = i; /* { dg-error "invalid conversion" } */ + obj_C = j; /* { dg-error "cannot convert" } */ + + i = obj; /* { dg-error "invalid conversion" } */ + i = obj_p; /* { dg-error "invalid conversion" } */ + i = obj_c; /* { dg-error "invalid conversion" } */ + i = obj_C; /* { dg-error "invalid conversion" } */ + + j = obj; /* { dg-error "cannot convert" } */ + j = obj_p; /* { dg-error "cannot convert" } */ + j = obj_c; /* { dg-error "cannot convert" } */ + j = obj_C; /* { dg-error "cannot convert" } */ + + if (obj == i) ; /* { dg-error "comparison between pointer and integer" } */ + if (i == obj) ; /* { dg-error "comparison between pointer and integer" } */ + if (obj == j) ; /* { dg-error "lacks a cast" } */ + if (j == obj) ; /* { dg-error "lacks a cast" } */ + + if (obj_c == i) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (i == obj_c) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (obj_c == j) ; /* { dg-error "lacks a cast" } */ + if (j == obj_c) ; /* { dg-error "lacks a cast" } */ + + if (obj_p == i) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (i == obj_p) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (obj_p == j) ; /* { dg-error "lacks a cast" } */ + if (j == obj_p) ; /* { dg-error "lacks a cast" } */ + + if (obj_C == i) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (i == obj_C) ; /*{ dg-error "comparison between pointer and integer" }*/ + if (obj_C == j) ; /* { dg-error "lacks a cast" } */ + if (j == obj_C) ; /* { dg-error "lacks a cast" } */ + + return 0; +} |