From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/objc.dg/sync-3.m | 128 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 gcc/testsuite/objc.dg/sync-3.m (limited to 'gcc/testsuite/objc.dg/sync-3.m') diff --git a/gcc/testsuite/objc.dg/sync-3.m b/gcc/testsuite/objc.dg/sync-3.m new file mode 100644 index 000000000..5cee890bb --- /dev/null +++ b/gcc/testsuite/objc.dg/sync-3.m @@ -0,0 +1,128 @@ +/* Contributed by Nicola Pero , December 2010. */ +/* { dg-options "-fobjc-exceptions" } */ +/* { dg-do compile } */ + +/* Test that the compiler is checking the argument of @synchronized(), + and produce errors when invalid types are used. */ + +#include + +@interface MyObject +{ + Class isa; +} +@end + +@implementation MyObject +@end + +@protocol MyProtocol; + +typedef MyObject MyObjectTypedef; +typedef MyObject *MyObjectPtrTypedef; +typedef int intTypedef; + +typedef struct { float x; float y; } point, *point_ptr; + +int test (id object) +{ + int dummy = 0; + + { + int x; + @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + } + + { + intTypedef x; + @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + } + + { + int *x; + @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + } + + { + point x; + @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + } + + { + point_ptr x; + @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + } + + { + id x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + id x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + MyObject *x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + MyObject *x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + static MyObject *x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + MyObjectTypedef *x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + MyObjectTypedef *x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + MyObjectPtrTypedef x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + { + Class x; + @synchronized (x) /* Ok */ + { dummy++; } + } + + @synchronized (1) /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + + @synchronized ("Test") /* { dg-error ".@synchronized. argument is not an object" } */ + { dummy++; } + + @synchronized () /* { dg-error "expected expression" } */ + { dummy++; } + + @synchronized (int) /* { dg-error "expected expression" } */ + { dummy++; } + + return dummy; +} -- cgit v1.2.3