OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [attributes/] [method-nonnull-1.m] - Blame information for rev 704

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, May 2011.  */
2
/* { dg-do compile } */
3
/* { dg-options "-Wall" } */
4
 
5
#include <objc/objc.h>
6
#include <stdlib.h>
7
 
8
@interface MyArray
9
{
10
  Class isa;
11
}
12
+ (void) addObject: (id)object __attribute__ ((nonnull));
13
- (void) addObject: (id)object __attribute__ ((nonnull));
14
 
15
+ (void) insertObject: (id)object  atIndex: (size_t)index __attribute__ ((nonnull (1)));
16
- (void) insertObject: (id)object  atIndex: (size_t)index __attribute__ ((nonnull (1)));
17
 
18
+ (void) insertObject: (id)object  atIndex: (size_t)index  andObject: (id)anotherObject  atIndex: (size_t)anotherIndex __attribute__ ((nonnull (1, 3)));
19
- (void) insertObject: (id)object  atIndex: (size_t)index  andObject: (id)anotherObject  atIndex: (size_t)anotherIndex __attribute__ ((nonnull (1, 3)));
20
 
21
/* Test the behaviour with invalid code.  */
22
+ (void) removeObject: (id)object __attribute__ ((nonnull (0))); /* { dg-error "out-of-range" } */
23
- (void) removeObject: (id)object __attribute__ ((nonnull (0))); /* { dg-error "out-of-range" } */
24
 
25
+ (void) removeObject: (id)object __attribute__ ((nonnull (2))); /* { dg-error "out-of-range" } */
26
- (void) removeObject: (id)object __attribute__ ((nonnull (2))); /* { dg-error "out-of-range" } */
27
 
28
+ (void) removeObjectAtIndex: (size_t)object __attribute__ ((nonnull (1))); /* { dg-error "non-pointer operand" } */
29
- (void) removeObjectAtIndex: (size_t)object __attribute__ ((nonnull (1))); /* { dg-error "non-pointer operand" } */
30
 
31
+ (void) removeObject: (id)object __attribute__ ((nonnull (MyArray))); /* { dg-error "invalid operand" } */
32
- (void) removeObject: (id)object __attribute__ ((nonnull (MyArray))); /* { dg-error "invalid operand" } */
33
@end
34
 
35
void test (MyArray *object)
36
{
37
  [object addObject: object];
38
  [object addObject: nil]; /* { dg-warning "null argument where non-null required" } */
39
 
40
  [object insertObject: object atIndex: 4];
41
  [object insertObject: nil    atIndex: 4]; /* { dg-warning "null argument where non-null required" } */
42
 
43
  [object insertObject: object atIndex: 2 andObject: object atIndex: 3];
44
  [object insertObject: nil    atIndex: 2 andObject: object atIndex: 3]; /* { dg-warning "null argument where non-null required" } */
45
  [object insertObject: object atIndex: 2 andObject: nil    atIndex: 3]; /* { dg-warning "null argument where non-null required" } */
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.